Sparse writing (Scilab gateway) — How to write sparse matrix in a gateway.
Input argument profile:
SciErr createSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, int* _piNbItemRow, int* _piColPos, double* _pdblReal)
SciErr createComplexSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, int* _piNbItemRow, int* _piColPos, double* _pdblReal, double* _pdblImg)
Named variable profile:
SciErr createNamedSparseMatrix(void* _pvCtx, char* _pstName, int _iRows, int _iCols, int _iNbItem, int* _piNbItemRow, int* _piColPos, double* _pdblReal)
SciErr createNamedComplexSparseMatrix(void* _pvCtx, char* _pstName, int _iRows, int _iCols, int _iNbItem, int* _piNbItemRow, int* _piColPos, double* _pdblReal, double* _pdblImg)
Scilab environment pointer, pass in "pvApiCtx" provided by api_scilab.h
Position in the Scilab memory where you want to put the variable.
Name of the variable for "named" functions.
Number of rows of the new variable.
Number of columns of the new variable.
Number of non zero itmes in the sparse.
Number of item in each rows (size: _iRows).
Column position for each item (size: _iNbItem).
Address of real data array (size: _iNbItem).
Address of imaginary data array (size: _iNbItem).
This argument does not exist with createSparseMatrix and createNamedSparseMatrix.
Error structure where is stored errors messages history and first error number.
Input argument profile:
SciErr allocSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal)
SciErr allocComplexSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg)
Scilab environment pointer, pass in "pvApiCtx" provided by api_scilab.h.
Position in the Scilab memory where you want to put the variable.
Number of rows of the new variable.
Number of columns of the new variable.
Number of non zero itmes in the sparse.
Return address of number of item in each rows (size: _iRows).
Return address of column position for each item (size: _iNbItem).
Address of real data array (size: _iNbItem).
Address of imaginary data array (size: _iNbItem).
This argument does not exist with allocSparseMatrix.
Error structure where is stored errors messages history and first error number.
This help describes how to add sparse matrix.
Two types of functions can be used to write in the memory of Scilab.
int write_sparse(char *fname,unsigned long fname_len) { SciErr sciErr; int piNbItemRow[] = {1,2,1}; int piColPos[] = {8,4,7,2}; double pdblSReal[] = {1,2,3,4}; double pdblSImg[] = {4,3,2,1}; int iNbItem = 4; sciErr = createComplexSparseMatrix(pvApiCtx, Rhs + 1, 3, 10, iNbItem, piNbItemRow, piColPos, pdblSReal, pdblSImg); if(sciErr.iErr) { printError(&sciErr, 0); return 0; } LhsVar(1) = 1; return 0; }