Scilab 5.5.1
- Aide de Scilab
- API Scilab
- Low level functions
- AssignOutputVariable
- CallOverloadFunction
- CheckInputArgument
- CheckOutputArgument
- ReturnArguments
- Boolean reading (Scilab gateway)
- Boolean writing (Scilab gateway)
- Boolean sparse reading (Scilab gateway)
- Boolean sparse writing (Scilab gateway)
- Check variable dimensions (Scilab gateway)
- Variable Reference (Scilab gateway)
- Variable dimension (Scilab gateway)
- Variable Type (Scilab gateway)
- Variable Complexity (Scilab gateway)
- Matrix Type (Scilab gateway)
- deleteNamedVariable
- Double reading (Scilab gateway)
- Double writing (Scilab gateway)
- getNbInputArgument (Scilab gateway)
- getNbOutputArgument (Scilab gateway)
- Handle reading (Scilab gateway)
- Handle writing (Scilab gateway)
- Integer Precision (Scilab gateway)
- Integer reading (Scilab gateway)
- Integer writing (Scilab gateway)
- nbInputArgument (Scilab gateway)
- Pointer reading (Scilab gateway)
- Pointer writing (Scilab gateway)
- Polynomial Symbolic Variable (Scilab gateway)
- Polynomial reading (Scilab gateway)
- Polynomial writing (Scilab gateway)
- Sparse matrix reading (Scilab gateway)
- Sparse writing (Scilab gateway)
- String reading (Scilab gateway)
- String writing (Scilab gateway)
Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
However, this page did not exist in the previous stable version.
Matrix Type (Scilab gateway)
How to know if an argument or a variable is stored as a matrix.
Calling Sequence
Input argument profile:
int isVarMatrixType(void* _pvCtx, int* _piAddress)
Named variable profile:
int isNamedVarMatrixType(void* _pvCtx, const char *_pstName)
Arguments
- _pvCtx
Scilab environment pointer, pass in "pvApiCtx" provided by api_scilab.h
- _piAddress
Address of the variable
- Returned value
1 if the variable is stored as matrix otherwise 0.
Description
This help describes how to know if a variable is stored as a matrix.
In some cases (exemple: list), a variable is not stored as a standard Scilab matrix. This function provides a way to handle both cases.
Gateway Source
#include "api_scilab.h" SciErr printf_info(int _iVar); int common_function(char *fname,unsigned long fname_len) { SciErr sciErr; int i; int *piAddr1 = NULL; int iBool = 0; for(i = 0 ; i < nbInputArgument(pvApiCtx) ; i++) { sciErr = printf_info(i + 1); if(sciErr.iErr) { printError(&sciErr, 0); break; } sciprint("\n\n"); } //1 for true, 0 for false iBool = sciErr.iErr == 0 ? 1 : 0; sciErr = createMatrixOfBoolean(pvApiCtx, nbInputArgument(pvApiCtx) + 1, 1, 1, &iBool); if(sciErr.iErr) { printError(&sciErr, 0); return 0; } //assign allocated variables to Lhs position AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; return 0; } SciErr printf_info(int _iVar) { SciErr sciErr; int* piAddr = NULL; int iType = 0; int iRows = 0; int iCols = 0; int iItem = 0; int iComplex = 0; sciErr = getVarAddressFromPosition(pvApiCtx, _iVar, &piAddr); if(sciErr.iErr) { return sciErr; } sciprint("Variable %d information:\n", _iVar); sciErr = getVarType(pvApiCtx, piAddr, &iType); if(sciErr.iErr) { return sciErr; } sciprint("\tType: "); switch(iType) { case sci_matrix : sciprint("double\n"); break; case sci_poly : sciprint("polynomial\n"); break; case sci_boolean : sciprint("boolean\n"); break; case sci_sparse : sciprint("sparse\n"); break; case sci_boolean_sparse : sciprint("boolean_sparse\n"); break; case sci_ints : { char pstSigned[] = "signed"; char pstUnsigned[] = "unsigned"; char* pstSign = pstSigned; int iPrec = 0; sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddr, &iPrec); if(sciErr.iErr) { return sciErr; } if(iPrec > 10) { pstSign = pstUnsigned; } sciprint("%s integer %d bits\n", pstSign, (iPrec % 10) * 8); } break; case sci_strings : sciprint("strings\n"); break; case sci_list : sciprint("list\n"); break; case sci_tlist : sciprint("tlist\n"); break; case sci_mlist : sciprint("mlist\n"); break; default : sciprint("Not manage by this function\n"); return sciErr; } if(isVarComplex(pvApiCtx, piAddr)) { sciprint("\tComplex: Yes\n"); } sciprint("\tDimensions: "); if(isVarMatrixType(pvApiCtx, piAddr)) { sciErr = getVarDimension(pvApiCtx, piAddr, &iRows, &iCols); if(sciErr.iErr) { return sciErr; } sciprint("%d x %d", iRows, iCols); } else { sciErr = getListItemNumber(pvApiCtx, piAddr, &iItem); if(sciErr.iErr) { return sciErr; } sciprint("%d", iItem); } return sciErr; }
Scilab test script
Report an issue | ||
<< Variable Complexity (Scilab gateway) | Low level functions | deleteNamedVariable >> |