My Project
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
14namespace 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
132}
133
134#if AF_API_VERSION >= 31
135
136#define AF_PRINT1(exp) af::print(#exp, exp);
137#define AF_PRINT2(exp, precision) af::print(#exp, exp, precision);
138
139#define GET_PRINT_MACRO(_1, _2, NAME, ...) NAME
140
141#define af_print(...) GET_PRINT_MACRO(__VA_ARGS__, AF_PRINT2, AF_PRINT1)(__VA_ARGS__)
142
143#else // AF_API_VERSION
144
145#define af_print(exp) af::print(#exp, exp);
146
147#endif // AF_API_VERSION
148
149#endif //__cplusplus
150
151#ifdef __cplusplus
152extern "C" {
153#endif
154
163
164#if AF_API_VERSION >= 31
174 AFAPI af_err af_print_array_gen(const char *exp, const af_array arr, const int precision);
175#endif
176
177#if AF_API_VERSION >= 31
188 AFAPI af_err af_save_array(int *index, const char* key, const af_array arr, const char *filename, const bool append);
189#endif
190
191#if AF_API_VERSION >= 31
201 AFAPI af_err af_read_array_index(af_array *out, const char *filename, const unsigned index);
202#endif
203
204#if AF_API_VERSION >= 31
214 AFAPI af_err af_read_array_key(af_array *out, const char *filename, const char* key);
215#endif
216
217#if AF_API_VERSION >= 31
228 AFAPI af_err af_read_array_key_check(int *index, const char *filename, const char* key);
229#endif
230
231#if AF_API_VERSION >= 31
243 AFAPI af_err af_array_to_string(char **output, const char *exp, const af_array arr,
244 const int precision, const bool transpose);
245#endif
246
247 // Purpose of Addition: "How to add Function" documentation
249
253 AFAPI af_err af_get_version(int *major, int *minor, int *patch);
254
255
256#if AF_API_VERSION >= 33
262 AFAPI const char *af_get_revision();
263#endif
264
265#ifdef __cplusplus
266}
267#endif
A multi dimensional data container.
Definition array.h:27
Wrapper for af_index.
Definition index.h:52
af_err
Definition defines.h:63
void * af_array
Definition defines.h:222
#define AFAPI
Definition defines.h:31
af_someenum_t
Definition defines.h:380
AFAPI array exp(const array &in)
C++ Interface for exponential of an array.
AFAPI array transpose(const array &in, const bool conjugate=false)
Transposes a matrix.
AFAPI af_err af_print_array(af_array arr)
AFAPI af_err af_print_array_gen(const char *exp, const af_array arr, const int precision)
AFAPI void print(const char *exp, const array &arr)
AFAPI af_err af_array_to_string(char **output, const char *exp, const af_array arr, const int precision, const bool transpose)
AFAPI void toString(char **output, const char *exp, const array &arr, const int precision=4, const bool transpose=true)
AFAPI array sum(const array &in, const int dim=-1)
C++ Interface for sum of elements in an array.
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...
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 af_err af_read_array_key(af_array *out, const char *filename, const char *key)
AFAPI array readArray(const char *filename, const unsigned index)
AFAPI af_err af_read_array_index(af_array *out, const char *filename, const unsigned index)
AFAPI af_err af_save_array(int *index, const char *key, const af_array arr, const char *filename, const bool append)
AFAPI int saveArray(const char *key, const array &arr, const char *filename, const bool append=false)
Definition algorithm.h:15
AFAPI array exampleFunction(const array &in, const af_someenum_t param)
AFAPI af_err af_example_function(af_array *out, const af_array in, const af_someenum_t param)
AFAPI af_err af_get_version(int *major, int *minor, int *patch)
Get the version information of the library.
AFAPI const char * af_get_revision()
Get the revision (commit) information of the library.