1 /* 2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Copyright (C) 2009 - DIGITEO - Antoine ELIAS 4 * 5 * Copyright (C) 2012 - 2016 - Scilab Enterprises 6 * 7 * This file is hereby licensed under the terms of the GNU GPL v2.0, 8 * pursuant to article 5.3.4 of the CeCILL v.2.1. 9 * This file was originally licensed under the terms of the CeCILL v2.1, 10 * and continues to be available under such terms. 11 * For more information, see the COPYING file which you should have received 12 * along with this program. 13 */ 14 15 #ifndef __STACK_SPARSE_API__ 16 #define __STACK_SPARSE_API__ 17 18 #if !defined(__INTERNAL_API_SCILAB__) 19 #error Do not include api_stack_sparse.h. Include api_scilab.h instead. 20 #endif 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 #include "dynlib_api_scilab.h" 27 28 /*****************************/ 29 /* sparse matrix functions */ 30 /*****************************/ 31 32 /** 33 * Get sparse variable data 34 * @param[in] _piAddress variable address 35 * @param[out] _piRows return number of rows 36 * @param[out] _piCols return number of columns 37 * @param[out] _piNbItem return number of items 38 * @param[out] _piNbItemRow return array of numbers of items for each row 39 * @param[out] _piColPos return array of item column positions ( 1 indexed ) 40 * @param[out] _pdblReal return pointer to real data 41 * @return if the operation succeeded ( 0 ) or not ( !0 ) 42 */ 43 SciErr getSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal); 44 45 /** 46 * Get complex sparse variable data 47 * @param[in] _piAddress variable address 48 * @param[out] _piRows return number of rows 49 * @param[out] _piCols return number of columns 50 * @param[out] _piNbItem number of items 51 * @param[out] _piNbItemRow return array of numbers of items for each row 52 * @param[out] _piColPos return array of item column positions ( 1 indexed ) 53 * @param[out] _pdblReal return pointer to real parts 54 * @param[out] _pdblImg return pointer to imaginary parts 55 * @return if the operation succeeded ( 0 ) or not ( !0 ) 56 */ 57 SciErr getComplexSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg); 58 59 /** 60 * Allocate a sparse variable 61 * @param[in] _iVar variable number 62 * @param[in] _iRows number of rows 63 * @param[in] _iCols number of columns 64 * @param[in] _iNbItem number of items 65 * @param[out] _piNbItemRow return array of numbers of items for each row 66 * @param[out] _piColPos return array of item column position ( 1 indexed ) 67 * @param[out] _pdblReal return pointer to data 68 * @return if the operation succeeded ( 0 ) or not ( !0 ) 69 */ 70 SciErr allocSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal); 71 72 /** 73 * Allocate a complex sparse variable 74 * @param[in] _iVar variable number 75 * @param[in] _iRows number of rows 76 * @param[in] _iCols number of columns 77 * @param[in] _iNbItem number of items 78 * @param[out] _piNbItemRow return array of numbers of items for each row 79 * @param[out] _piColPos return array of item column positions ( 1 indexed ) 80 * @param[out] _pdblReal return pointer to real parts 81 * @param[out] _pdblImg return pointer to imaginary parts 82 * @return if the operation succeeded ( 0 ) or not ( !0 ) 83 */ 84 SciErr allocComplexSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg); 85 86 /** 87 * Create a sparse double variable 88 * @param[in] _iVar variable number 89 * @param[in] _iRows nmber of rows 90 * @param[in] _iCols number of columns 91 * @param[in] _iNbItem number of items 92 * @param[in] _piNbItemRow array of numbers of items for each row 93 * @param[in] _piColPos array of item column positions ( 1 indexed ) 94 * @param[in] _pdblReal pointer to real data 95 * @return if the operation succeeded ( 0 ) or not ( !0 ) 96 */ 97 SciErr createSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, const int* _piNbItemRow, const int* _piColPos, const double* _pdblReal); 98 99 /** 100 * Create a complex sparse double variable 101 * @param[in] _iVar variable number 102 * @param[in] _iRows number of rows 103 * @param[in] _iCols number of columns 104 * @param[in] _iNbItem number of items 105 * @param[in] _piNbItemRow array of numbers of items for each row 106 * @param[in] _piColPos array of item column positions ( 1 indexed ) 107 * @param[in] _pdblReal pointer to real parts 108 * @param[in] _pdblImg pointer to imaginary parts 109 * @return if the operation succeeded ( 0 ) or not ( !0 ) 110 */ 111 SciErr createComplexSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, const int* _piNbItemRow, const int* _piColPos, const double* _pdblReal, const double* _pdblImg); 112 113 /** 114 * Create a named sparse double variable 115 * @param[in] _pstName variable name 116 * @param[in] _iRows number of rows 117 * @param[in] _iCols number of columns 118 * @param[in] _iNbItem number of items 119 * @param[in] _piNbItemRow array of numbers of items for each row 120 * @param[in] _piColPos array of item column positions ( 1 indexed ) 121 * @param[in] _pdblReal pointer to real data 122 * @return if the operation succeeded ( 0 ) or not ( !0 ) 123 */ 124 SciErr createNamedSparseMatrix(void* _pvCtx, const char* _pstName, int _iRows, int _iCols, int _iNbItem, const int* _piNbItemRow, const int* _piColPos, const double* _pdblReal); 125 126 /** 127 * Create a named complex sparse double variable 128 * @param[in] _pstName variable name 129 * @param[in] _iRows number of rows 130 * @param[in] _iCols number of columns 131 * @param[in] _iNbItem number of items 132 * @param[in] _piNbItemRow array of number of items for each row 133 * @param[in] _piColPos array of item column positions ( 1 indexed ) 134 * @param[in] _pdblReal pointer to real parts 135 * @param[int] _pdblImg pointer to imaginary parts 136 * @return if the operation succeeded ( 0 ) or not ( !0 ) 137 */ 138 SciErr createNamedComplexSparseMatrix(void* _pvCtx, const char* _pstName, int _iRows, int _iCols, int _iNbItem, const int* _piNbItemRow, const int* _piColPos, const double* _pdblReal, const double* _pdblImg); 139 140 /** 141 * Read named sparse double variable 142 * @param[in] _pstName variable name 143 * @param[out] _piRows return number of rows 144 * @param[out] _piCols return number of columns 145 * @param[out] _piNbItem return number of items 146 * @param[out] _piNbItemRow return array of numbers of items for each row 147 * @param[out] _piColPos return array of item column positions ( 1 indexed ) 148 * @param[out] _pdblReal pointer to real data 149 * @return if the operation succeeded ( 0 ) or not ( !0 ) 150 */ 151 SciErr readNamedSparseMatrix(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int* _piNbItemRow, int* _piColPos, double* _pdblReal); 152 153 /** 154 * Read a named complex sparse double variable 155 * @param[in] _pstName variable name 156 * @param[out] _piRows return number of rows 157 * @param[out] _piCols return number of columns 158 * @param[out] _piNbItem return number of items 159 * @param[out] _piNbItemRow return array of number of items for each row 160 * @param[out] _piColPos return array of item column position ( 1 indexed ) 161 * @param[out] _pdblReal pointer to real parts 162 * @param[out] _pdblImg pointer to imaginary parts 163 * @return if the operation succeeded ( 0 ) or not ( !0 ) 164 */ 165 SciErr readNamedComplexSparseMatrix(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int* _piNbItemRow, int* _piColPos, double* _pdblReal, double* _pdblImg); 166 167 /* shortcut functions */ 168 169 /** 170 * Check if the variable type is sparse double 171 * @param[in] _piAddress variable address 172 * @return 1 for true and 0 for false 173 */ 174 int isSparseType(void* _pvCtx, int* _piAddress); 175 176 /** 177 * Check if the variable type is sparse double 178 * @param[in] _pstName variable name 179 * @return 1 for true and 0 for false 180 */ 181 int isNamedSparseType(void* _pvCtx, const char* _pstName); 182 183 /** 184 * Get sparse variable data 185 * @param[in] _piAddress variable address 186 * @param[out] _piRows return number of rows 187 * @param[out] _piCols return number of columns 188 * @param[out] _piNbItem return number of items 189 * @param[out] _piNbItemRow return array of numbers of items for each row 190 * @param[out] _piColPos return array of item column positions ( 1 indexed ) 191 * @param[out] _pdblReal return pointer to real data 192 * @return if the operation succeeded ( 0 ) or not ( !0 ) 193 */ 194 int getAllocatedSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal); 195 196 /** 197 * Get complex sparse variable data 198 * @param[in] _piAddress variable address 199 * @param[out] _piRows return number of rows 200 * @param[out] _piCols return number of columns 201 * @param[out] _piNbItem return number of items 202 * @param[out] _piNbItemRow return array of numbers of items for each row 203 * @param[out] _piColPos return array of item column positions ( 1 indexed ) 204 * @param[out] _pdblReal return pointer to real parts 205 * @param[out] _pdblImg return pointer to imaginary parts 206 * @return if the operation succeeded ( 0 ) or not ( !0 ) 207 */ 208 int getAllocatedComplexSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg); 209 210 /** 211 * Get named sparse variable data 212 * @param[in] _pstName variable name 213 * @param[out] _piRows return number of rows 214 * @param[out] _piCols return number of columns 215 * @param[out] _piNbItem return number of items 216 * @param[out] _piNbItemRow return array of numbers of items for each row 217 * @param[out] _piColPos return array of item column positions ( 1 indexed ) 218 * @param[out] _pdblReal return pointer to real data 219 * @return if the operation succeeded ( 0 ) or not ( !0 ) 220 */ 221 int getNamedAllocatedSparseMatrix(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal); 222 223 /** 224 * Get named complex sparse variable data 225 * @param[in] _pstName variable name 226 * @param[out] _piRows return number of rows 227 * @param[out] _piCols return number of columns 228 * @param[out] _piNbItem return number of items 229 * @param[out] _piNbItemRow return array of numbers of items for each row 230 * @param[out] _piColPos return array of item column position ( 1 indexed ) 231 * @param[out] _pdblReal return pointer to real parts 232 * @param[out] _pdblImg return pointer to imaginary parts 233 * @return if the operation succeeded ( 0 ) or not ( !0 ) 234 */ 235 int getNamedAllocatedComplexSparseMatrix(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg); 236 237 238 /** 239 * Free memory allocated for a sparse matrix (named or not) by shortcut functions 240 * @param[in] _piNbItemRow array of numbers of items for each row 241 * @param[in] _piColPos array of item column position ( 1 indexed ) 242 * @param[in] _pdblReal pointer to real data 243 */ 244 void freeAllocatedSparseMatrix(int* _piNbItemRows, int* _piColPos, double* _pdblReal); 245 246 /** 247 * Free memory allocated for a complex sparse matrix (named or not) by shortcut functions 248 * @param[in] _piNbItemRow array of numbers of items for each row 249 * @param[in] _piColPos array of item column positions ( 1 indexed ) 250 * @param[in] _pdblReal pointer to real parts 251 * @param[in] _pdblImg pointer to imaginary parts 252 */ 253 void freeAllocatedComplexSparseMatrix(int* _piNbItemRows, int* _piColPos, double* _pdblReal, double* _pdblImg); 254 255 #ifdef __cplusplus 256 } 257 #endif 258 #endif /* __STACK_SPARSE_API__ */ 259