Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.3.0 - Português

Change language to:
English - Français - 日本語 -

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.

Manual Scilab >> API Scilab > List manipulation > Integer writing (Scilab gateway)

Integer writing (Scilab gateway)

How to add matrix of integer in a list.

Create from existing data.

Calling Sequence

Input argument profile:

Signed integer :

SciErr createMatrixOfInteger8InList(void* _pvCtx, int _iVar, int* _piParent, int _iItemPos, int _iRows, int _iCols, const char* _pcData)
SciErr createMatrixOfInteger16InList(void* _pvCtx, int _iVar, int* _piParent, int _iItemPos, int _iRows, int _iCols, const short* _psData)
SciErr createMatrixOfInteger32InList(void* _pvCtx, int _iVar, int* _piParent, int _iItemPos, int _iRows, int _iCols, const int* _piData)

Unsigned integer :

SciErr createMatrixOfUnsignedInteger8InList(void* _pvCtx, int _iVar, int* _piParent, int _iItemPos, int _iRows, int _iCols, const unsigned char* _pucData)
SciErr createMatrixOfUnsignedInteger16InList(void* _pvCtx, int _iVar, int* _piParent, int _iItemPos, int _iRows, int _iCols, const unsigned short* _pusData)
SciErr createMatrixOfUnsignedInteger32InList(void* _pvCtx, int _iVar, int* _piParent, int _iItemPos, int _iRows, int _iCols, const unsigned int* _puiData)

Named variable profile:

Signed integer :

SciErr createMatrixOfInteger8InNamedList(void* _pvCtx, const char* _pstName, int* _piParent, int _iItemPos, int _iRows, int _iCols, const char* _pcData)
SciErr createMatrixOfInteger16InNamedList(void* _pvCtx, const char* _pstName, int* _piParent, int _iItemPos, int _iRows, int _iCols, const short* _psData)
SciErr createMatrixOfInteger32InNamedList(void* _pvCtx, const char* _pstName, int* _piParent, int _iItemPos, int _iRows, int _iCols, const int* _piData)

Unsigned integer :

SciErr createMatrixOfUnsignedInteger8InNamedList(void* _pvCtx, const char* _pstName, int* _piParent, int _iItemPos, int _iRows, int _iCols, const unsigned char* _pucData)
SciErr createMatrixOfUnsignedInteger16InNamedList(void* _pvCtx, const char* _pstName, int* _piParent, int _iItemPos, int _iRows, int _iCols, const unsigned short* _pusData)
SciErr createMatrixOfUnsignedInteger32InNamedList(void* _pvCtx, const char* _pstName, int* _piParent, int _iItemPos, int _iRows, int _iCols, const unsigned int* _puiData)

Arguments

_pvCtx

Scilab environment pointer, pass in "pvApiCtx" provided by api_scilab.h.

_iVar

Position in the Scilab memory where you want to put the variable.

_pstName

Name of the variable for "named" functions.

_piParent

Address of the parent of the new item.

_iItemPos

Position of the new item in the list.

_iRows

Number of rows of the new variable.

_iCols

Number of columns of the new variable.

_pcData8, _psData16, _piData32, _pucData8, _pusData16, _puiData32

Address of data array (size: _iCols * _iRows)

SciErr

Error structure where is stored errors messages history and first error number.

Write directly in Scilab memory.

Calling Sequence

Input argument profile:

Signed integer :

SciErr allocMatrixOfInteger8InList(void* _pvCtx, int _iVar, int* _piParent, int _iItemPos, int _iRows, int _iCols, char** _pcData)
SciErr allocMatrixOfInteger16InList(void* _pvCtx, int _iVar, int* _piParent, int _iItemPos, int _iRows, int _iCols, short** _psData)
SciErr allocMatrixOfInteger32InList(void* _pvCtx, int _iVar, int* _piParent, int _iItemPos, int _iRows, int _iCols, int** _piData)

Unsigned integer :

SciErr allocMatrixOfUnsignedInteger8InList(void* _pvCtx, int _iVar, int* _piParent, int _iItemPos, int _iRows, int _iCols, unsigned char** _pucData)
SciErr allocMatrixOfUnsignedInteger16InList(void* _pvCtx, int _iVar, int* _piParent, int _iItemPos, int _iRows, int _iCols, unsigned short** _pusData)
SciErr allocMatrixOfUnsignedInteger32InList(void* _pvCtx, int _iVar, int* _piParent, int _iItemPos, int _iRows, int _iCols, unsigned int** _puiData)

Arguments

_pvCtx

Scilab environment pointer, pass in "pvApiCtx" provided by api_scilab.h.

_iVar

Position in the Scilab memory where you want to put the variable.

_piParent

Address of the parent of the new item.

_iItemPos

Position of the new item in the list.

_iRows

Number of rows of the new variable.

_iCols

Number of columns of the new variable.

_pcData8, _psData16, _piData32, _pucData8, _pusData16, _puiData32

Return address of data array (size: _iCols * _iRows)

SciErr

Error structure where is stored errors messages history and first error number.

Description

This help describes how to add matrix of integer in a list.

Two types of functions can be used to write in the memory of Scilab.

Gateway Source

int list_createlist(char *fname,unsigned long fname_len)
{
    SciErr sciErr;
    int *piAddr             = NULL;
    int* piChild            = NULL;
    double pdblData1[]      = {1,3,5,2,4,6};
    double pdblData2[]      = {6,4,2,5,3,1};
    char *pstData[]         = {"may","be","the","with","puffin","you"};
    short psData[]          = {1,4,2,5,3,6};
    double pdblPoly1[]      = {1};
    double pdblPoly2[]      = {-2,-1};
    double pdblPoly3[]      = {1,2,3};
    double pdblPoly4[]      = {-4,-3,-2,-1};
    double pdblPoly5[]      = {1,2,3,4,5};
    double pdblPoly6[]      = {-6,-5,-4,-3,-2,-1};
    double *pdblPoly[]      = {pdblPoly1, pdblPoly3, pdblPoly5, pdblPoly2, pdblPoly4, pdblPoly6};
    int piCoef[]            = {1,3,5,2,4,6};
    int piNbItemRow[]       = {1,2,1};
    int piColPos[]          = {8,4,7,2};
    double pdblSReal[]      = {1,2,3,4};
    double pdblSImg[]       = {4,3,2,1};
    int piBool[]            = {1,0,1,0,1,0,1,0,1};
    double* pdblDataPtr     = NULL;

    sciErr = createList(pvApiCtx, Rhs + 1, 8, &piAddr);
    if(sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }

    sciErr = createComplexMatrixOfDoubleInList(pvApiCtx, Rhs + 1, piAddr, 1, 3, 2, pdblData1, pdblData2);
    if(sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }

    sciErr = createMatrixOfStringInList(pvApiCtx, Rhs + 1, piAddr, 2, 2, 3, pstData);
    if(sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }

    sciErr = createMatrixOfInteger16InList(pvApiCtx, Rhs + 1, piAddr, 3, 2, 3, psData);
    if(sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }

    sciErr = createMatrixOfPolyInList(pvApiCtx, Rhs + 1, piAddr, 4, "x", 3, 2, piCoef, pdblPoly);
    if(sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }

    sciErr = createComplexSparseMatrixInList(pvApiCtx, Rhs + 1, piAddr, 5, 3, 10, 4, piNbItemRow, piColPos, pdblSReal, pdblSImg);
    if(sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }

    sciErr = createMatrixOfBooleanInList(pvApiCtx, Rhs + 1, piAddr, 6, 3, 3, piBool);
    if(sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }

    sciErr = createBooleanSparseMatrixInList(pvApiCtx, Rhs + 1, piAddr, 7, 3, 10, 4, piNbItemRow, piColPos);
    if(sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }

    //add list in list
    sciErr = createListInList(pvApiCtx, Rhs + 1, piAddr, 8, 3, &piChild);
    if(sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }

    sciErr = createMatrixOfDoubleInList(pvApiCtx, Rhs + 1, piChild, 1, 3, 2, pdblData1);
    if(sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }

    sciErr = createSparseMatrixInList(pvApiCtx, Rhs + 1, piChild, 2, 3, 10, 4, piNbItemRow, piColPos, pdblSReal);
    if(sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }

    pdblDataPtr     = (double*)malloc(sizeof(double) * 4);
    pdblDataPtr[0]  = 1;
    pdblDataPtr[1]  = 2;
    pdblDataPtr[2]  = 3;
    pdblDataPtr[3]  = 4;

    sciErr = createPointerInList(pvApiCtx, Rhs + 1, piChild, 3, pdblDataPtr);
    if(sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }

    LhsVar(1) = Rhs + 1;
    return 0;
}

Scilab test script

size_ref    = 8;
type_ref    = ["constant","string","int16","polynomial", "sparse", "boolean", "boolean sparse", "list"];
dim_ref     = list([3,2],[2,3],[2,3],[3,2],[3,10],[3,3],[3,10],3);

l = list_createlist();
if size(l) <> size_ref then error("failed"), end
for i = 1 : size_ref
    if typeof(l(i)) <> type_ref(i) then error("failed"), end
    if size(l(i)) <> dim_ref(i) then error("failed"), end
end
<< Integer reading (Scilab gateway) List manipulation Pointer reading (Scilab gateway) >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Wed Jan 26 16:24:43 CET 2011