sparse.h Source File

sparse.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
18 #if AF_API_VERSION >= 34
19
37 AFAPI array sparse(const dim_t nRows, const dim_t nCols,
38 const array values, const array rowIdx, const array colIdx,
39 const af::storage stype = AF_STORAGE_CSR);
40 #endif
41
42 #if AF_API_VERSION >= 34
43
65 AFAPI array sparse(const dim_t nRows, const dim_t nCols, const dim_t nNZ,
66 const void* const values,
67 const int * const rowIdx, const int * const colIdx,
68 const dtype type = f32, const af::storage stype = AF_STORAGE_CSR,
69 const af::source src = afHost);
70 #endif
71
72 #if AF_API_VERSION >= 34
73
82 AFAPI array sparse(const array dense, const af::storage stype = AF_STORAGE_CSR);
83 #endif
84
85 #if AF_API_VERSION >= 34
86
93 AFAPI array sparseConvertTo(const array in, const af::storage destStrorage);
94 #endif
95
96 #if AF_API_VERSION >= 34
97
103 AFAPI array dense(const array sparse);
104 #endif
105
106 #if AF_API_VERSION >= 34
107
116 AFAPI void sparseGetInfo(array &values, array &rowIdx, array &colIdx, af::storage &stype,
117 const array in);
118 #endif
119
120 #if AF_API_VERSION >= 34
121
127 AFAPI array sparseGetValues(const array in);
128 #endif
129
130 #if AF_API_VERSION >= 34
131
137 AFAPI array sparseGetRowIdx(const array in);
138 #endif
139
140 #if AF_API_VERSION >= 34
141
147 AFAPI array sparseGetColIdx(const array in);
148 #endif
149
150 #if AF_API_VERSION >= 34
151
157 AFAPI dim_t sparseGetNNZ(const array in);
158 #endif
159
160 #if AF_API_VERSION >= 34
161
167 AFAPI af::storage sparseGetStorage(const array in);
168 #endif
169 }
170 #endif
171
172 #ifdef __cplusplus
173 extern "C" {
174 #endif
175
176 #if AF_API_VERSION >= 34
177
197 AFAPI af_err af_create_sparse_array(
198 af_array *out,
199 const dim_t nRows, const dim_t nCols,
200 const af_array values, const af_array rowIdx, const af_array colIdx,
201 const af_storage stype);
202 #endif
203
204 #if AF_API_VERSION >= 34
205
229 AFAPI af_err af_create_sparse_array_from_ptr(
230 af_array *out,
231 const dim_t nRows, const dim_t nCols, const dim_t nNZ,
232 const void * const values,
233 const int * const rowIdx, const int * const colIdx,
234 const af_dtype type, const af_storage stype,
235 const af_source src);
236 #endif
237
238 #if AF_API_VERSION >= 34
239
250 AFAPI af_err af_create_sparse_array_from_dense(
251 af_array *out, const af_array dense,
252 const af_storage stype);
253 #endif
254
255 #if AF_API_VERSION >= 34
256
265 AFAPI af_err af_sparse_convert_to(af_array *out, const af_array in,
266 const af_storage destStorage);
267 #endif
268
269 #if AF_API_VERSION >= 34
270
278 AFAPI af_err af_sparse_to_dense(af_array *out, const af_array sparse);
279 #endif
280
281 #if AF_API_VERSION >= 34
282
293 AFAPI af_err af_sparse_get_info(af_array *values, af_array *rowIdx, af_array *colIdx, af_storage *stype,
294 const af_array in);
295 #endif
296
297 #if AF_API_VERSION >= 34
298
306 AFAPI af_err af_sparse_get_values(af_array *out, const af_array in);
307 #endif
308
309 #if AF_API_VERSION >= 34
310
318 AFAPI af_err af_sparse_get_row_idx(af_array *out, const af_array in);
319 #endif
320
321 #if AF_API_VERSION >= 34
322
330 AFAPI af_err af_sparse_get_col_idx(af_array *out, const af_array in);
331 #endif
332
333 #if AF_API_VERSION >= 34
334
342 AFAPI af_err af_sparse_get_nnz(dim_t *out, const af_array in);
343 #endif
344
345 #if AF_API_VERSION >= 34
346
354 AFAPI af_err af_sparse_get_storage(af_storage *out, const af_array in);
355 #endif
356
357 #ifdef __cplusplus
358 }
359 #endif
af_sparse_get_row_idx
AFAPI af_err af_sparse_get_row_idx(af_array *out, const af_array in)
af::sparseConvertTo
AFAPI array sparseConvertTo(const array in, const af::storage destStrorage)
af_sparse_get_nnz
AFAPI af_err af_sparse_get_nnz(dim_t *out, const af_array in)
af
Definition: algorithm.h:14
af::sparseGetStorage
AFAPI af::storage sparseGetStorage(const array in)
af_sparse_to_dense
AFAPI af_err af_sparse_to_dense(af_array *out, const af_array sparse)
af_create_sparse_array
AFAPI af_err af_create_sparse_array(af_array *out, const dim_t nRows, const dim_t nCols, const af_array values, const af_array rowIdx, const af_array colIdx, const af_storage stype)
This function converts af::array of values, row indices and column indices into a sparse array...
af_sparse_convert_to
AFAPI af_err af_sparse_convert_to(af_array *out, const af_array in, const af_storage destStorage)
af_create_sparse_array_from_dense
AFAPI af_err af_create_sparse_array_from_dense(af_array *out, const af_array dense, const af_storage stype)
This function converts a dense af_array into a sparse array.
af::dense
AFAPI array dense(const array sparse)
af::sparse
AFAPI array sparse(const dim_t nRows, const dim_t nCols, const array values, const array rowIdx, const array colIdx, const af::storage stype=AF_STORAGE_CSR)
This function converts af::array of values, row indices and column indices into a sparse array...
af_storage
af_storage
Definition: defines.h:450
af_sparse_get_col_idx
AFAPI af_err af_sparse_get_col_idx(af_array *out, const af_array in)
af_err
af_err
Definition: defines.h:63
af_create_sparse_array_from_ptr
AFAPI af_err af_create_sparse_array_from_ptr(af_array *out, const dim_t nRows, const dim_t nCols, const dim_t nNZ, const void *const values, const int *const rowIdx, const int *const colIdx, const af_dtype type, const af_storage stype, const af_source src)
This function converts host or device arrays of values, row indices and column indices into a sparse ...
af_source
af_source
Definition: defines.h:214
defines.h
AF_STORAGE_CSR
Storage type is CSR.
Definition: defines.h:452
af::sparseGetNNZ
AFAPI dim_t sparseGetNNZ(const array in)
dim_t
long long dim_t
Definition: defines.h:50
af::sparseGetRowIdx
AFAPI array sparseGetRowIdx(const array in)
AFAPI
#define AFAPI
Definition: defines.h:31
af_sparse_get_values
AFAPI af_err af_sparse_get_values(af_array *out, const af_array in)
af::sparseGetValues
AFAPI array sparseGetValues(const array in)
af::sparseGetInfo
AFAPI void sparseGetInfo(array &values, array &rowIdx, array &colIdx, af::storage &stype, const array in)
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:327
af_sparse_get_info
AFAPI af_err af_sparse_get_info(af_array *values, af_array *rowIdx, af_array *colIdx, af_storage *stype, const af_array in)
af::sparseGetColIdx
AFAPI array sparseGetColIdx(const array in)
af_sparse_get_storage
AFAPI af_err af_sparse_get_storage(af_storage *out, const af_array in)
af_array
void * af_array
Definition: defines.h:222
f32
32-bit floating point values
Definition: defines.h:196
afHost
Host pointer.
Definition: defines.h:216
af_dtype
af_dtype
Definition: defines.h:195
af::dtype
af_dtype dtype
Definition: defines.h:461