- Main Page
- Tutorials
- Functions
- Release Notes
- Examples

defines.h
Go to the documentation of this file.
1 /*******************************************************
2 * Copyright (c) 2014, ArrayFire
3 * All rights reserved.
4 *
5 * This file is distributed under 3-clause BSD license.
6 * The complete license agreement can be obtained at:
7 * http://arrayfire.com/licenses/BSD-3-Clause
8 ********************************************************/
9
10 #pragma once
11
12 #if defined(_WIN32) || defined(_MSC_VER)
13 // http://msdn.microsoft.com/en-us/library/b0084kay(v=VS.80).aspx
14 // http://msdn.microsoft.com/en-us/library/3y1sfaz2%28v=VS.80%29.aspx
15 #ifdef AFDLL // libaf
16 #define AFAPI __declspec(dllexport)
17 #else
18 #define AFAPI __declspec(dllimport)
19 #endif
20
21 // bool
22 #ifndef __cplusplus
23 #define bool unsigned char
24 #define false 0
25 #define true 1
26 #endif
27 #define __PRETTY_FUNCTION__ __FUNCSIG__
28 #define SIZE_T_FRMT_SPECIFIER "%Iu"
29 #define DEPRECATED(msg) __declspec(deprecated( msg ))
30 #else
31 #define AFAPI __attribute__((visibility("default")))
32 #include <stdbool.h>
33 #define SIZE_T_FRMT_SPECIFIER "%zu"
34 #if __GNUC__ >= 4 && __GNUC_MINOR > 4
35 #define DEPRECATED(msg) __attribute__((deprecated( msg )))
36 #else
37 #define DEPRECATED(msg) __attribute__((deprecated))
38 #endif
39
40 #endif
41
42 // Known 64-bit x86 and ARM architectures use long long
43 #if defined(__x86_64__) || defined(_M_X64) || defined(_WIN64) || defined(__aarch64__) || defined(__LP64__) // 64-bit Architectures
44 typedef long long dim_t;
45 // Known 32-bit x86 and ARM architectures use int
46 #elif defined(__i386__) || defined(_M_IX86) || defined(__arm__) || defined(_M_ARM) // 32-bit x86 Architecture
47 typedef int dim_t;
48 // All other platforms use long long
49 #else
50 typedef long long dim_t;
51 #endif
52
53 #if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86) || defined(_WIN64)
54 #define USE_CPUID
55 #endif
56
57 #include <stdlib.h>
58
59 typedef long long intl;
60 typedef unsigned long long uintl;
61
62 #include <af/version.h>
63 #ifndef AF_API_VERSION
64 #define AF_API_VERSION AF_API_VERSION_CURRENT
65 #endif
66
67 typedef enum {
71 AF_SUCCESS = 0,
72
73 // 100-199 Errors in environment
74
78 AF_ERR_NO_MEM = 101,
79
83 AF_ERR_DRIVER = 102,
84
88 AF_ERR_RUNTIME = 103,
89
90 // 200-299 Errors in input parameters
91
95 AF_ERR_INVALID_ARRAY = 201,
96
100 AF_ERR_ARG = 202,
101
105 AF_ERR_SIZE = 203,
106
110 AF_ERR_TYPE = 204,
111
115 AF_ERR_DIFF_TYPE = 205,
116
120 AF_ERR_BATCH = 207,
121
122
123 // 300-399 Errors for missing software features
124
128 AF_ERR_NOT_SUPPORTED = 301,
129
133 AF_ERR_NOT_CONFIGURED = 302,
134
138 AFF_ERR_NONFREE = 303,
139
140 // 400-499 Errors for missing hardware features
141
145 AF_ERR_NO_DBL = 401,
146
151 AF_ERR_NO_GFX = 402,
152 // 900-999 Errors from upstream libraries and runtimes
153
158 AF_ERR_INTERNAL = 998,
159
163 AF_ERR_UNKNOWN = 999
164 } af_err;
165
166 typedef enum {
167 f32,
168 c32,
169 f64,
170 c64,
171 b8,
172 s32,
173 u32,
174 u8,
175 s64,
176 u64
177 } af_dtype;
178
179 typedef enum {
180 afDevice,
181 afHost,
182 } af_source;
183
184 #define AF_MAX_DIMS 4
185
186 // A handle for an internal array object
187 typedef void * af_array;
188
189 typedef enum {
190 AF_INTERP_NEAREST,
191 AF_INTERP_LINEAR,
192 AF_INTERP_BILINEAR,
193 AF_INTERP_CUBIC,
194 AF_INTERP_LOWER
195 } af_interp_type;
196
197 typedef enum {
201 AF_PAD_ZERO = 0,
202
206 AF_PAD_SYM
207 } af_border_type;
208
209 typedef enum {
213 AF_CONNECTIVITY_4 = 4,
214
218 AF_CONNECTIVITY_8 = 8
219 } af_connectivity;
220
221 typedef enum {
222
226 AF_CONV_DEFAULT,
227
231 AF_CONV_EXPAND,
232 } af_conv_mode;
233
234 typedef enum {
235 AF_CONV_AUTO,
236 AF_CONV_SPATIAL,
237 AF_CONV_FREQ,
238 } af_conv_domain;
239
240 typedef enum {
241 AF_SAD = 0,
242 AF_ZSAD,
243 AF_LSAD,
244 AF_SSD,
245 AF_ZSSD,
246 AF_LSSD,
247 AF_NCC,
248 AF_ZNCC,
249 AF_SHD
250 } af_match_type;
251
252 typedef enum {
253 AF_YCC_601 = 601,
254 AF_YCC_709 = 709,
255 AF_YCC_2020 = 2020
256 } af_ycc_std;
257
258 typedef enum {
259 AF_GRAY = 0,
260 AF_RGB,
261 AF_HSV,
262 AF_YCbCr
263 } af_cspace_t;
264
265 typedef enum {
266 AF_MAT_NONE = 0,
267 AF_MAT_TRANS = 1,
268 AF_MAT_CTRANS = 2,
269 AF_MAT_CONJ = 4,
270 AF_MAT_UPPER = 32,
271 AF_MAT_LOWER = 64,
272 AF_MAT_DIAG_UNIT = 128,
273 AF_MAT_SYM = 512,
274 AF_MAT_POSDEF = 1024,
275 AF_MAT_ORTHOG = 2048,
276 AF_MAT_TRI_DIAG = 4096,
277 AF_MAT_BLOCK_DIAG = 8192
278 } af_mat_prop;
279
280 typedef enum {
281 AF_NORM_VECTOR_1,
282 AF_NORM_VECTOR_INF,
283 AF_NORM_VECTOR_2,
284 AF_NORM_VECTOR_P,
285 AF_NORM_MATRIX_1,
286 AF_NORM_MATRIX_INF,
287 AF_NORM_MATRIX_2,
288 AF_NORM_MATRIX_L_PQ,
289
290 AF_NORM_EUCLID = AF_NORM_VECTOR_2,
291 } af_norm_type;
292
293 typedef enum {
294 AF_COLORMAP_DEFAULT = 0,
295 AF_COLORMAP_SPECTRUM= 1,
296 AF_COLORMAP_COLORS = 2,
297 AF_COLORMAP_RED = 3,
298 AF_COLORMAP_MOOD = 4,
299 AF_COLORMAP_HEAT = 5,
300 AF_COLORMAP_BLUE = 6
301 } af_colormap;
302
303 typedef enum {
304 AF_FIF_BMP = 0,
305 AF_FIF_ICO = 1,
306 AF_FIF_JPEG = 2,
307 AF_FIF_JNG = 3,
308 AF_FIF_PNG = 13,
309 AF_FIF_PPM = 14,
310 AF_FIF_PPMRAW = 15,
311 AF_FIF_TIFF = 18,
312 AF_FIF_PSD = 20,
313 AF_FIF_HDR = 26,
314 AF_FIF_EXR = 29,
315 AF_FIF_JP2 = 31,
316 AF_FIF_RAW = 34
317 } af_image_format;
318
319 // Below enum is purely added for example purposes
320 // it doesn't and shoudn't be used anywhere in the
321 // code. No Guarantee's provided if it is used.
322 typedef enum {
323 AF_ID = 0
324 } af_someenum_t;
325
326 #ifdef __cplusplus
327 namespace af
328 {
329 typedef af_dtype dtype;
330 typedef af_source source;
331 typedef af_interp_type interpType;
332 typedef af_border_type borderType;
333 typedef af_connectivity connectivity;
334 typedef af_match_type matchType;
335 typedef af_cspace_t CSpace;
336 typedef af_someenum_t SomeEnum; // Purpose of Addition: How to add Function example
337 typedef af_mat_prop trans;
338 typedef af_conv_mode convMode;
339 typedef af_conv_domain convDomain;
340 typedef af_mat_prop matProp;
341 typedef af_colormap ColorMap;
342 typedef af_norm_type normType;
343 typedef af_ycc_std YCCStd;
344 typedef af_image_format imageFormat;
345 }
346
347 #endif
AF_ERR_NO_MEM
The system or device ran out of memory.
Definition: defines.h:78
af::source
af_source source
Definition: defines.h:330
af_ycc_std
af_ycc_std
Definition: defines.h:252
AF_MAT_SYM
Matrix is symmetric.
Definition: defines.h:273
AF_NORM_MATRIX_2
returns the max singular value). Currently NOT SUPPORTED
Definition: defines.h:287
AF_SSD
Match based on Sum of Squared Differences (SSD)
Definition: defines.h:244
af::SomeEnum
af_someenum_t SomeEnum
Definition: defines.h:336
af::ColorMap
af_colormap ColorMap
Definition: defines.h:341
AF_INTERP_CUBIC
Cubic Interpolation.
Definition: defines.h:193
AF_MAT_ORTHOG
Matrix is orthogonal.
Definition: defines.h:275
AF_INTERP_LINEAR
Linear Interpolation.
Definition: defines.h:191
af
Definition: algorithm.h:14
AF_ID
Definition: defines.h:323
afDevice
Device pointer.
Definition: defines.h:180
AF_FIF_RAW
FreeImage Enum for RAW Camera Image File.
Definition: defines.h:316
AF_FIF_JNG
FreeImage Enum for JPEG Network Graphics File.
Definition: defines.h:307
AF_SUCCESS
The function returned successfully.
Definition: defines.h:71
af_norm_type
af_norm_type
Definition: defines.h:280
af_border_type
af_border_type
Definition: defines.h:197
AF_YCC_709
ITU-R BT.709 standard.
Definition: defines.h:254
AF_ERR_DIFF_TYPE
The type of the input arrays are not compatible.
Definition: defines.h:115
AF_CONV_EXPAND
Output of the convolution is signal_len + filter_len - 1.
Definition: defines.h:231
AF_FIF_BMP
FreeImage Enum for Bitmap File.
Definition: defines.h:304
AF_COLORMAP_BLUE
Blue hue map.
Definition: defines.h:300
AF_MAT_UPPER
Matrix is upper triangular.
Definition: defines.h:270
AF_YCbCr
3-channel YCbCr
Definition: defines.h:262
AF_MAT_DIAG_UNIT
Matrix diagonal contains unitary values.
Definition: defines.h:272
AF_CONV_DEFAULT
Output of the convolution is the same size as input.
Definition: defines.h:226
AF_COLORMAP_MOOD
Mood map.
Definition: defines.h:298
s32
32-bit signed integral values
Definition: defines.h:172
AF_ERR_BATCH
Function does not support GFOR / batch mode.
Definition: defines.h:120
af::YCCStd
af_ycc_std YCCStd
Definition: defines.h:343
AF_MAT_POSDEF
Matrix is positive definite.
Definition: defines.h:274
AF_ERR_NOT_SUPPORTED
The option is not supported.
Definition: defines.h:128
AF_FIF_ICO
FreeImage Enum for Windows Icon File.
Definition: defines.h:305
AF_ZSAD
Match based on Zero mean SAD.
Definition: defines.h:242
s64
64-bit signed integral values
Definition: defines.h:175
AF_ZSSD
Match based on Zero mean SSD.
Definition: defines.h:245
AF_GRAY
Grayscale.
Definition: defines.h:259
AF_ZNCC
Match based on Zero mean NCC.
Definition: defines.h:248
AF_MAT_NONE
Default.
Definition: defines.h:266
af_interp_type
af_interp_type
Definition: defines.h:189
AF_LSSD
Match based on Locally scaled SSD.
Definition: defines.h:246
AF_FIF_JPEG
FreeImage Enum for JPEG File.
Definition: defines.h:306
AF_MAT_CTRANS
Data needs to be conjugate tansposed.
Definition: defines.h:268
f64
64-bit complex floating point values
Definition: defines.h:169
AF_NCC
Match based on Normalized Cross Correlation (NCC)
Definition: defines.h:247
AF_NORM_VECTOR_P
treats the input as a vector and returns the p-norm
Definition: defines.h:284
af::imageFormat
af_image_format imageFormat
Definition: defines.h:344
af_conv_domain
af_conv_domain
Definition: defines.h:234
AF_FIF_PSD
FreeImage Enum for Adobe Photoshop File.
Definition: defines.h:312
af_colormap
af_colormap
Definition: defines.h:293
AF_MAT_CONJ
Data needs to be conjugate.
Definition: defines.h:269
AF_NORM_MATRIX_INF
return the max of row sums
Definition: defines.h:286
AF_FIF_PPM
FreeImage Enum for Portable Pixelmap (ASCII) File.
Definition: defines.h:309
AF_ERR_RUNTIME
There was an error with the runtime environment.
Definition: defines.h:88
AF_PAD_SYM
Out of bound values are symmetric over the edge.
Definition: defines.h:206
AF_COLORMAP_SPECTRUM
Spectrum map.
Definition: defines.h:295
AF_HSV
3-channel HSV
Definition: defines.h:261
af_connectivity
af_connectivity
Definition: defines.h:209
AF_NORM_MATRIX_L_PQ
returns Lpq-norm
Definition: defines.h:288
AF_FIF_JP2
FreeImage Enum for JPEG-2000 File.
Definition: defines.h:315
af_err
af_err
Definition: defines.h:67
AF_LSAD
Match based on Locally scaled SAD.
Definition: defines.h:243
AF_ERR_TYPE
The type is not suppported by this function.
Definition: defines.h:110
af_source
af_source
Definition: defines.h:179
AF_CONNECTIVITY_4
Connectivity includes neighbors, North, East, South and West of current pixel.
Definition: defines.h:213
u64
64-bit unsigned integral values
Definition: defines.h:176
af_someenum_t
af_someenum_t
Definition: defines.h:322
af_conv_mode
af_conv_mode
Definition: defines.h:221
AF_YCC_601
ITU-R BT.601 (formerly CCIR 601) standard.
Definition: defines.h:253
AF_PAD_ZERO
Out of bound values are 0.
Definition: defines.h:201
AF_INTERP_BILINEAR
Bilinear Interpolation.
Definition: defines.h:192
AF_ERR_NO_DBL
This device does not support double.
Definition: defines.h:145
c64
64-bit complex floating point values
Definition: defines.h:170
dim_t
long long dim_t
Definition: defines.h:50
AF_ERR_NO_GFX
This build of ArrayFire was not built with graphics or this device does not support graphics...
Definition: defines.h:151
AF_ERR_NOT_CONFIGURED
This build of ArrayFire does not support this feature.
Definition: defines.h:133
AF_FIF_TIFF
FreeImage Enum for Tagged Image File Format File.
Definition: defines.h:311
AF_CONV_AUTO
ArrayFire automatically picks the right convolution algorithm.
Definition: defines.h:235
c32
32-bit complex floating point values
Definition: defines.h:168
af::matProp
af_mat_prop matProp
Definition: defines.h:340
af::normType
af_norm_type normType
Definition: defines.h:342
AF_NORM_VECTOR_INF
treats the input as a vector and returns the max of absolute values
Definition: defines.h:282
AF_MAT_BLOCK_DIAG
Matrix is block diagonal.
Definition: defines.h:277
AF_ERR_DRIVER
There was an error in the device driver.
Definition: defines.h:83
AF_CONNECTIVITY_8
Connectivity includes 4-connectivity neigbors and also those on Northeast, Northwest, Southeast and Southwest.
Definition: defines.h:218
af::convDomain
af_conv_domain convDomain
Definition: defines.h:339
AF_NORM_EUCLID
The default. Same as AF_NORM_VECTOR_2.
Definition: defines.h:290
u8
8-bit unsigned integral values
Definition: defines.h:174
af::borderType
af_border_type borderType
Definition: defines.h:332
AF_FIF_EXR
FreeImage Enum for ILM OpenEXR File.
Definition: defines.h:314
AF_CONV_SPATIAL
Perform convolution in spatial domain.
Definition: defines.h:236
AF_CONV_FREQ
Perform convolution in frequency domain.
Definition: defines.h:237
AF_SHD
Match based on Sum of Hamming Distances (SHD)
Definition: defines.h:249
AF_SAD
Match based on Sum of Absolute Differences (SAD)
Definition: defines.h:241
AF_MAT_TRANS
Data needs to be transposed.
Definition: defines.h:267
AF_NORM_MATRIX_1
return the max of column sums
Definition: defines.h:285
af::trans
af_mat_prop trans
Definition: defines.h:337
AF_ERR_ARG
One of the function arguments is incorrect.
Definition: defines.h:100
AF_INTERP_NEAREST
Nearest Interpolation.
Definition: defines.h:190
uintl
unsigned long long uintl
Definition: defines.h:60
AF_RGB
3-channel RGB
Definition: defines.h:260
af_mat_prop
af_mat_prop
Definition: defines.h:265
AF_ERR_INVALID_ARRAY
The input array is not a valid af_array object.
Definition: defines.h:95
u32
32-bit unsigned integral values
Definition: defines.h:173
AF_FIF_HDR
FreeImage Enum for High Dynamic Range File.
Definition: defines.h:313
af_cspace_t
af_cspace_t
Definition: defines.h:258
AF_COLORMAP_DEFAULT
Default grayscale map.
Definition: defines.h:294
AFF_ERR_NONFREE
This build of ArrayFire is not compiled with "nonfree" algorithms.
Definition: defines.h:138
AF_MAT_LOWER
Matrix is lower triangular.
Definition: defines.h:271
AF_FIF_PNG
FreeImage Enum for Portable Network Graphics File.
Definition: defines.h:308
AF_FIF_PPMRAW
FreeImage Enum for Portable Pixelmap (Binary) File.
Definition: defines.h:310
af_array
void * af_array
Definition: defines.h:187
af_image_format
af_image_format
Definition: defines.h:303
af::matchType
af_match_type matchType
Definition: defines.h:334
AF_MAT_TRI_DIAG
Matrix is tri diagonal.
Definition: defines.h:276
af::CSpace
af_cspace_t CSpace
Definition: defines.h:335
f32
32-bit floating point values
Definition: defines.h:167
AF_NORM_VECTOR_2
treats the input as a vector and returns euclidean norm
Definition: defines.h:283
AF_COLORMAP_HEAT
Heat map.
Definition: defines.h:299
AF_NORM_VECTOR_1
treats the input as a vector and returns the sum of absolute values
Definition: defines.h:281
version.h
b8
8-bit boolean values
Definition: defines.h:171
AF_INTERP_LOWER
Floor Indexed.
Definition: defines.h:194
afHost
Host pointer.
Definition: defines.h:181
af_dtype
af_dtype
Definition: defines.h:166
af::interpType
af_interp_type interpType
Definition: defines.h:331
af_match_type
af_match_type
Definition: defines.h:240
AF_COLORMAP_RED
Red hue map.
Definition: defines.h:297
AF_ERR_INTERNAL
There was an internal error either in ArrayFire or in a project upstream.
Definition: defines.h:158
af::convMode
af_conv_mode convMode
Definition: defines.h:338
AF_ERR_UNKNOWN
Unknown Error.
Definition: defines.h:163
af::dtype
af_dtype dtype
Definition: defines.h:329
intl
long long intl
Definition: defines.h:59
AF_COLORMAP_COLORS
Colors.
Definition: defines.h:296
AF_ERR_SIZE
The size is incorrect.
Definition: defines.h:105
af::connectivity
af_connectivity connectivity
Definition: defines.h:333
AF_YCC_2020
ITU-R BT.2020 standard.
Definition: defines.h:255