util.h Source File

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

util.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 #include <af/defines.h>
12
13 #ifdef __cplusplus
14 namespace af
15 {
16 class array;
17
24 AFAPI void print(const char *exp, const array &arr);
25
26 #if AF_API_VERSION >= 31
27
34 AFAPI void print(const char *exp, const array &arr, const int precision);
35 #endif
36
37 #if AF_API_VERSION >= 31
38
49 AFAPI int saveArray(const char *key, const array &arr, const char *filename, const bool append = false);
50 #endif
51
52 #if AF_API_VERSION >= 31
53
63 AFAPI array readArray(const char *filename, const unsigned index);
64 #endif
65
66 #if AF_API_VERSION >= 31
67
77 AFAPI array readArray(const char *filename, const char *key);
78 #endif
79
80 #if AF_API_VERSION >= 31
81
92 AFAPI int readArrayCheck(const char *filename, const char *key);
93 #endif
94
95 #if AF_API_VERSION >= 31
96
107 AFAPI void toString(char **output, const char *exp, const array &arr,
108 const int precision = 4, const bool transpose = true);
109 #endif
110
111 // Purpose of Addition: "How to add Function" documentation
112 AFAPI array exampleFunction(const array& in, const af_someenum_t param);
113 }
114
115 #if AF_API_VERSION >= 31
116
117 #define AF_PRINT1(exp) af::print(#exp, exp);
118 #define AF_PRINT2(exp, precision) af::print(#exp, exp, precision);
119
120 #define GET_PRINT_MACRO(_1, _2, NAME, ...) NAME
121
122 #define af_print(...) GET_PRINT_MACRO(__VA_ARGS__, AF_PRINT2, AF_PRINT1)(__VA_ARGS__)
123
124 #else // AF_API_VERSION
125
126 #define af_print(exp) af::print(#exp, exp);
127
128 #endif // AF_API_VERSION
129
130 #endif //__cplusplus
131
132 #ifdef __cplusplus
133 extern "C" {
134 #endif
135
143 AFAPI af_err af_print_array(af_array arr);
144
145 #if AF_API_VERSION >= 31
146
155 AFAPI af_err af_print_array_gen(const char *exp, const af_array arr, const int precision);
156 #endif
157
158 #if AF_API_VERSION >= 31
159
169 AFAPI af_err af_save_array(int *index, const char* key, const af_array arr, const char *filename, const bool append);
170 #endif
171
172 #if AF_API_VERSION >= 31
173
182 AFAPI af_err af_read_array_index(af_array *out, const char *filename, const unsigned index);
183 #endif
184
185 #if AF_API_VERSION >= 31
186
195 AFAPI af_err af_read_array_key(af_array *out, const char *filename, const char* key);
196 #endif
197
198 #if AF_API_VERSION >= 31
199
209 AFAPI af_err af_read_array_key_check(int *index, const char *filename, const char* key);
210 #endif
211
212 #if AF_API_VERSION >= 31
213
224 AFAPI af_err af_array_to_string(char **output, const char *exp, const af_array arr,
225 const int precision, const bool transpose);
226 #endif
227
228 // Purpose of Addition: "How to add Function" documentation
229 AFAPI af_err af_example_function(af_array* out, const af_array in, const af_someenum_t param);
230
234 AFAPI af_err af_get_version(int *major, int *minor, int *patch);
235
236 #ifdef __cplusplus
237 }
238 #endif
af::toString
AFAPI void toString(char **output, const char *exp, const array &arr, const int precision=4, const bool transpose=true)
af
Definition: algorithm.h:14
af_read_array_index
AFAPI af_err af_read_array_index(af_array *out, const char *filename, const unsigned index)
af::readArray
AFAPI array readArray(const char *filename, const unsigned index)
af_read_array_key
AFAPI af_err af_read_array_key(af_array *out, const char *filename, const char *key)
af::print
AFAPI void print(const char *exp, const array &arr)
af::readArrayCheck
AFAPI int readArrayCheck(const char *filename, const char *key)
When reading by key, it may be a good idea to run this function first to check for the key and then c...
af_example_function
AFAPI af_err af_example_function(af_array *out, const af_array in, const af_someenum_t param)
af_err
af_err
Definition: defines.h:67
af_print_array_gen
AFAPI af_err af_print_array_gen(const char *exp, const af_array arr, const int precision)
af_save_array
AFAPI af_err af_save_array(int *index, const char *key, const af_array arr, const char *filename, const bool append)
defines.h
af_someenum_t
af_someenum_t
Definition: defines.h:377
af_print_array
AFAPI af_err af_print_array(af_array arr)
af_get_version
AFAPI af_err af_get_version(int *major, int *minor, int *patch)
Get the version information of the library.
af_read_array_key_check
AFAPI af_err af_read_array_key_check(int *index, const char *filename, const char *key)
When reading by key, it may be a good idea to run this function first to check for the key and then c...
AFAPI
#define AFAPI
Definition: defines.h:31
af_array_to_string
AFAPI af_err af_array_to_string(char **output, const char *exp, const af_array arr, const int precision, const bool transpose)
af::saveArray
AFAPI int saveArray(const char *key, const array &arr, const char *filename, const bool append=false)
afcl::array
static af::array array(af::dim4 idims, cl_mem buf, af::dtype type, bool retain=false)
Create an af::array object from an OpenCL cl_mem buffer.
Definition: opencl.h:161
af::exp
AFAPI array exp(const array &in)
C++ Interface for exponential of an array.
af_array
void * af_array
Definition: defines.h:219
af::exampleFunction
AFAPI array exampleFunction(const array &in, const af_someenum_t param)
af::transpose
AFAPI array transpose(const array &in, const bool conjugate=false)
Transposes a matrix.