A high-performance general-purpose compute library

- Main Page
- Tutorials
- 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
34 AFAPI void print(const char *exp, const array &arr, const int precision);
35#endif
36
37#if AF_API_VERSION >= 31
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
63 AFAPI array readArray(const char *filename, const unsigned index);
64#endif
65
66#if AF_API_VERSION >= 31
77 AFAPI array readArray(const char *filename, const char *key);
78#endif
79
80#if AF_API_VERSION >= 31
92 AFAPI int readArrayCheck(const char *filename, const char *key);
93#endif
94
95#if AF_API_VERSION >= 31
108 AFAPI void toString(char **output, const char *exp, const array &arr,
109 const int precision = 4, const bool transpose = true);
110#endif
111
112#if AF_API_VERSION >= 33
126 AFAPI const char* toString(const char *exp, const array &arr,
127 const int precision = 4, const bool transpose = true);
128#endif
129
130 // Purpose of Addition: "How to add Function" documentation
131 AFAPI array exampleFunction(const array& in, const af_someenum_t param);
132
133#if AF_API_VERSION >= 34
137 AFAPI size_t getSizeOf(af::dtype type);
138#endif
139}
140
141#if AF_API_VERSION >= 31
142
143#define AF_PRINT1(exp) af::print(#exp, exp);
144#define AF_PRINT2(exp, precision) af::print(#exp, exp, precision);
145
146#define GET_PRINT_MACRO(_1, _2, NAME, ...) NAME
147
148#define af_print(...) GET_PRINT_MACRO(__VA_ARGS__, AF_PRINT2, AF_PRINT1)(__VA_ARGS__)
149
150#else // AF_API_VERSION
151
152#define af_print(exp) af::print(#exp, exp);
153
154#endif // AF_API_VERSION
155
156#endif //__cplusplus
157
158#ifdef __cplusplus
159 extern "C" {
160#endif
161
169 AFAPI af_err af_print_array(af_array arr);
170
171#if AF_API_VERSION >= 31
181 AFAPI af_err af_print_array_gen(const char *exp, const af_array arr, const int precision);
182#endif
183
184#if AF_API_VERSION >= 31
195 AFAPI af_err af_save_array(int *index, const char* key, const af_array arr, const char *filename, const bool append);
196#endif
197
198#if AF_API_VERSION >= 31
208 AFAPI af_err af_read_array_index(af_array *out, const char *filename, const unsigned index);
209#endif
210
211#if AF_API_VERSION >= 31
221 AFAPI af_err af_read_array_key(af_array *out, const char *filename, const char* key);
222#endif
223
224#if AF_API_VERSION >= 31
235 AFAPI af_err af_read_array_key_check(int *index, const char *filename, const char* key);
236#endif
237
238#if AF_API_VERSION >= 31
250 AFAPI af_err af_array_to_string(char **output, const char *exp, const af_array arr,
251 const int precision, const bool transpose);
252#endif
253
254 // Purpose of Addition: "How to add Function" documentation
255 AFAPI af_err af_example_function(af_array* out,
256 const af_array in,
257 const af_someenum_t param);
258
262 AFAPI af_err af_get_version(int *major, int *minor, int *patch);
263
264
265#if AF_API_VERSION >= 33
271 AFAPI const char *af_get_revision();
272#endif
273
274#if AF_API_VERSION >= 34
278 AFAPI af_err af_get_size_of(size_t *size, af_dtype type);
279#endif
280
281#if AF_API_VERSION >= 37
287 AFAPI af_err af_set_enable_stacktrace(int is_enabled);
288#endif
289
290#ifdef __cplusplus
291}
292#endif
af::array
A multi dimensional data container.
Definition array.h:37
af::index
Wrapper for af_index.
Definition index.h:52
defines.h
af_dtype
af_dtype
Definition defines.h:210
af_err
af_err
Definition defines.h:71
af_array
void * af_array
Definition defines.h:240
AFAPI
#define AFAPI
Definition defines.h:38
af_someenum_t
af_someenum_t
Definition defines.h:425
af::exp
array exp(const array &in)
C++ Interface to evaluate the exponential.
af::transpose
AFAPI array transpose(const array &in, const bool conjugate=false)
C++ Interface to transpose a matrix.
af_print_array
AFAPI af_err af_print_array(af_array arr)
af_print_array_gen
AFAPI af_err af_print_array_gen(const char *exp, const af_array arr, const int precision)
af::print
AFAPI void print(const char *exp, const array &arr)
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::toString
AFAPI void toString(char **output, const char *exp, const array &arr, const int precision=4, const bool transpose=true)
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_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...
af_read_array_key
AFAPI af_err af_read_array_key(af_array *out, const char *filename, const char *key)
af::readArray
AFAPI array readArray(const char *filename, const unsigned index)
af_read_array_index
AFAPI af_err af_read_array_index(af_array *out, const char *filename, const unsigned index)
af_save_array
AFAPI af_err af_save_array(int *index, const char *key, const af_array arr, const char *filename, const bool append)
af::saveArray
AFAPI int saveArray(const char *key, const array &arr, const char *filename, const bool append=false)
af
Definition algorithm.h:15
af::exampleFunction
AFAPI array exampleFunction(const array &in, const af_someenum_t param)
af::getSizeOf
AFAPI size_t getSizeOf(af::dtype type)
Get the size of the type represented by an af_dtype enum.
af_example_function
AFAPI af_err af_example_function(af_array *out, const af_array in, const af_someenum_t param)
af_get_version
AFAPI af_err af_get_version(int *major, int *minor, int *patch)
Get the version information of the library.
af_get_size_of
AFAPI af_err af_get_size_of(size_t *size, af_dtype type)
Get the size of the type represented by an af_dtype enum.
af_get_revision
AFAPI const char * af_get_revision()
Get the revision (commit) information of the library.
af_set_enable_stacktrace
AFAPI af_err af_set_enable_stacktrace(int is_enabled)
Enable(default) or disable error messages that display the stacktrace.