extern crate num;
use std::error::Error;
use std::fmt::{Display, Formatter};
use std::fmt::Error as FmtError;
use self::num::Complex;
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum AfError {
SUCCESS = 0,
ERR_NO_MEM = 101,
ERR_DRIVER = 102,
ERR_RUNTIME = 103,
ERR_INVALID_ARRAY = 201,
ERR_ARG = 202,
ERR_SIZE = 203,
ERR_TYPE = 204,
ERR_DIFF_TYPE = 205,
ERR_BATCH = 207,
ERR_DEVICE = 208,
ERR_NOT_SUPPORTED = 301,
ERR_NOT_CONFIGURED = 302,
ERR_NO_DBL = 401,
ERR_NO_GFX = 402,
ERR_INTERNAL = 998,
ERR_UNKNOWN = 999
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Backend {
DEFAULT = 0,
CPU = 1,
CUDA = 2,
OPENCL = 4
}
impl Display for Backend {
fn fmt(&self, f: &mut Formatter) -> Result<(), FmtError> {
let text = match *self {
Backend::OPENCL => "OpenCL",
Backend::CUDA => "Cuda",
Backend::CPU => "CPU",
Backend::DEFAULT => "Default",
};
write!(f, "{}", text)
}
}
impl Display for AfError {
fn fmt(&self, f: &mut Formatter) -> Result<(), FmtError> {
write!(f, "{}", self.description())
}
}
impl Error for AfError {
fn description(&self) -> &str {
match *self {
AfError::SUCCESS => "Function returned successfully",
AfError::ERR_NO_MEM => "System or Device ran out of memory",
AfError::ERR_DRIVER => "Error in the device driver",
AfError::ERR_RUNTIME => "Error with the runtime environment",
AfError::ERR_INVALID_ARRAY => "Iput Array is not a valid object",
AfError::ERR_ARG => "One of the function arguments is incorrect",
AfError::ERR_SIZE => "Size is incorrect",
AfError::ERR_TYPE => "Type is not suppported by this function",
AfError::ERR_DIFF_TYPE => "Type of the input arrays are not compatible",
AfError::ERR_BATCH => "Function does not support GFOR / batch mode",
AfError::ERR_DEVICE => "Input does not belong to the current device",
AfError::ERR_NOT_SUPPORTED => "Unsupported operation/parameter option",
AfError::ERR_NOT_CONFIGURED => "This build of ArrayFire does not support this feature",
AfError::ERR_NO_DBL => "This device does not support double",
AfError::ERR_NO_GFX => "This build of ArrayFire has no graphics support",
AfError::ERR_INTERNAL => "Error either in ArrayFire or in a project upstream",
AfError::ERR_UNKNOWN => "Unknown Error",
}
}
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum DType {
F32 = 0,
C32 = 1,
F64 = 2,
C64 = 3,
B8 = 4,
S32 = 5,
U32 = 6,
U8 = 7,
S64 = 8,
U64 = 9,
S16 = 10,
U16 = 11,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum InterpType {
NEAREST = 0,
LINEAR = 1,
BILINEAR= 2,
CUBIC = 3,
LOWER = 4,
LINEAR_COSINE = 5,
BILINEAR_COSINE = 6,
BICUBIC = 7,
CUBIC_SPLINE = 8,
BICUBIC_SPLINE = 9
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum BorderType {
ZERO = 0,
SYMMETRIC = 1,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Connectivity {
FOUR = 4,
EIGHT = 8
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ConvMode {
DEFAULT = 0,
EXPAND = 1,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ConvDomain {
AUTO = 0,
SPATIAL = 1,
FREQUENCY= 2,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum MatchType {
SAD = 0,
ZSAD= 1,
LSAD= 2,
SSD = 3,
ZSSD= 4,
LSSD= 5,
NCC = 6,
ZNCC= 7,
SHD = 8,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ColorSpace {
GRAY = 0,
RGB = 1,
HSV = 2,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum MatProp {
NONE,
TRANS,
CTRANS,
UPPER,
LOWER,
DIAGUNIT,
SYM,
POSDEF,
ORTHOG,
TRIDIAG,
BLOCKDIAG,
}
#[allow(non_camel_case_types)]
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum NormType {
VECTOR_1 = 0,
VECTOR_INF = 1,
VECTOR_2 = 2,
VECTOR_P = 3,
MATRIX_1 = 4,
MATRIX_INF = 5,
MATRIX_2 = 6,
MATRIX_L_PQ = 7,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ColorMap {
DEFAULT = 0,
SPECTRUM= 1,
COLORS = 2,
RED = 3,
MOOD = 4,
HEAT = 5,
BLUE = 6,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum YCCStd {
YCC_601 = 601,
YCC_709 = 709,
YCC_2020 = 2020,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum HomographyType {
RANSAC = 0,
LMEDS = 1,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum MarkerType {
NONE = 0,
POINT = 1,
CIRCLE = 2,
SQUARE = 3,
TRIANGLE = 4,
CROSS = 5,
PLUS = 6,
STAR = 7
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum MomentType {
M00 = 1, M01 = 2, M10 = 4, M11 = 8, FIRST_ORDER = 1<<0 | 1<<1 | 1<<2 | 1<<3
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum SparseFormat {
DENSE = 0,
CSR = 1,
CSC = 2,
COO = 3
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum BinaryOp {
ADD = 0,
MUL = 1,
MIN = 2,
MAX = 3
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum RandomEngineType {
PHILOX_4X32_10 = 100,
THREEFRY_2X32_16 = 200,
MERSENNE_GP11213 = 300
}
pub const PHILOX : RandomEngineType = RandomEngineType::PHILOX_4X32_10;
pub const THREEFRY : RandomEngineType = RandomEngineType::THREEFRY_2X32_16;
pub const MERSENNE : RandomEngineType = RandomEngineType::MERSENNE_GP11213;
pub const DEFAULT_RANDOM_ENGINE : RandomEngineType = PHILOX;
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Scalar {
F32(f32),
C32(Complex<f32>),
F64(f64),
C64(Complex<f64>),
B8(bool),
S32(i32),
U32(u32),
U8(u8),
S64(i64),
U64(u64),
S16(i16),
U16(u16),
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum CannyThresholdType {
MANUAL = 0,
OTSU = 1,
}