How to write sparse matrix in a gateway.
Input argument profile:
SciErr createSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, const int* _piNbItemRow, const int* _piColPos, const double* _pdblReal)
SciErr createComplexSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, const int* _piNbItemRow, const int* _piColPos, const double* _pdblReal, const double* _pdblImg)
Named variable profile:
SciErr createNamedSparseMatrix(void* _pvCtx, const char* _pstName, int _iRows, int _iCols, int _iNbItem, const int* _piNbItemRow, const int* _piColPos, const double* _pdblReal)
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)
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.
#include "api_scilab.h" int write_sparse(char *fname,void* pvApiCtx) { 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, nbInputArgument(pvApiCtx) + 1, 3, 10, iNbItem, piNbItemRow, piColPos, pdblSReal, pdblSImg); if(sciErr.iErr) { printError(&sciErr, 0); return 0; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; return 0; }