Scilab 5.5.2
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.
getHypermatOfInt
Get a hypermatrix of integer variable.
Calling Sequence
SciErr getHypermatOfInt8(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, char* _pcData)
SciErr getHypermatOfUnsignedInt8(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, unsigned char* _pucData)
SciErr getHypermatOfInt16(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, short* _psData)
SciErr getHypermatOfUnsignedInt16(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, unsigned short* _pusData)
SciErr getHypermatOfInt32(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, int* _piData)
SciErr getHypermatOfUnsignedInt32(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, unsigned int* _puiData)
Arguments
- _pvCtx
Scilab environment pointer, pass in "pvApiCtx" provided by api_scilab.h.
- _piAddress
Address of the Scilab variable.
- _dims
the hypermatrix dimensions.
- _ndims
the number of dimensions.
- _p*Data
the data.
Return value
A SciErr struct, the field iErr would contain the error number (0 if no error).
Gateway Source
#include "api_scilab.h" #include "Scierror.h" #include "localization.h" #include "sciprint.h" #include "MALLOC.h" int hypermatIntExample(char *fname,unsigned long fname_len) { SciErr sciErr; int* piAddr = NULL; int iType = 0; int iRet = 0; CheckInputArgument(pvApiCtx, 1, 1); CheckOutputArgument(pvApiCtx, 0, 1); sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr); if (sciErr.iErr) { printError(&sciErr, 0); return 0; } if (isEmptyMatrix(pvApiCtx, piAddr)) { iRet = createEmptyMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1); if (iRet) { return iRet; } AssignOutputVariable(pvApiCtx, 1) = 0; } else if (isHypermatType(pvApiCtx, piAddr)) { int * dims = NULL; int ndims; void * data = NULL; int htype = 0; int precision; sciErr = getHypermatType(pvApiCtx, piAddr, &htype); if (sciErr.iErr) { printError(&sciErr, 0); return sciErr.iErr; } if (htype == sci_ints) { sciErr = getHypermatOfIntegerPrecision(pvApiCtx, piAddr, &precision); if (sciErr.iErr) { printError(&sciErr, 0); return sciErr.iErr; } switch (precision) { case SCI_INT8: sciErr = getHypermatOfInteger8(pvApiCtx, piAddr, &dims, &ndims, (char*)&data); if(sciErr.iErr) { printError(&sciErr, 0); return sciErr.iErr; } sciErr = createHypermatOfInteger8(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const char*)data); if (sciErr.iErr) { printError(&sciErr, 0); return sciErr.iErr; } break; case SCI_UINT8: sciErr = getHypermatOfUnsignedInteger8(pvApiCtx, piAddr, &dims, &ndims, (unsigned char*)&data); if(sciErr.iErr) { printError(&sciErr, 0); return sciErr.iErr; } sciErr = createHypermatOfUnsignedInteger8(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned char*)data); if (sciErr.iErr) { printError(&sciErr, 0); return sciErr.iErr; } break; case SCI_INT16: sciErr = getHypermatOfInteger16(pvApiCtx, piAddr, &dims, &ndims, (short*)&data); if(sciErr.iErr) { printError(&sciErr, 0); return sciErr.iErr; } sciErr = createHypermatOfInteger16(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const short*)data); if (sciErr.iErr) { printError(&sciErr, 0); return sciErr.iErr; } break; case SCI_UINT16: sciErr = getHypermatOfUnsignedInteger16(pvApiCtx, piAddr, &dims, &ndims, (unsigned short*)&data); if(sciErr.iErr) { printError(&sciErr, 0); return sciErr.iErr; } sciErr = createHypermatOfUnsignedInteger16(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned short*)data); if (sciErr.iErr) { printError(&sciErr, 0); return sciErr.iErr; } break; case SCI_INT32: sciErr = getHypermatOfInteger32(pvApiCtx, piAddr, &dims, &ndims, (int*)&data); if(sciErr.iErr) { printError(&sciErr, 0); return sciErr.iErr; } sciErr = createHypermatOfInteger32(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const int*)data); if (sciErr.iErr) { printError(&sciErr, 0); return sciErr.iErr; } break; case SCI_UINT32: sciErr = getHypermatOfUnsignedInteger32(pvApiCtx, piAddr, &dims, &ndims, (unsigned int*)&data); if(sciErr.iErr) { printError(&sciErr, 0); return sciErr.iErr; } sciErr = createHypermatOfUnsignedInteger32(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned int*)data); if (sciErr.iErr) { printError(&sciErr, 0); return sciErr.iErr; } break; } } else { Scierror(999, _("%s: Wrong type for input argument #%d: An integer expected.\n"), fname, 1); return 1; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; } return 0; }
Scilab test script
a = hypermat([1 2 3], int8(1:6)); b = hypermat([1 2 3], uint8(1:6)); c = hypermat([1 2 3], int16(1:6)); d = hypermat([1 2 3], uint16(1:6)); e = hypermat([1 2 3], int32(1:6)); f = hypermat([1 2 3], uint32(1:6)); hypermatExampleInt(a) == a hypermatExampleInt(b) == b hypermatExampleInt(c) == c hypermatExampleInt(d) == d hypermatExampleInt(e) == e hypermatExampleInt(f) == f
Report an issue | ||
<< getHypermatOfDouble | hypermat | integer >> |