1
<?xml version="1.0" encoding="utf-8"?>
3
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4
* Copyright (C) 2009 - DIGITEO - Antoine ELIAS
6
* This file must be used under the terms of the CeCILL.
7
* This source file is licensed as described in the file COPYING, which
8
* you should have received as part of this distribution. The terms
9
* are also available at
10
* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
13
<refentry version="5.0-subset Scilab" xml:id="Common_getvardimension_API"
14
xml:lang="en" xmlns="http://docbook.org/ns/docbook"
15
xmlns:xlink="http://www.w3.org/1999/xlink"
16
xmlns:svg="http://www.w3.org/2000/svg"
17
xmlns:ns5="http://www.w3.org/1999/xhtml"
18
xmlns:mml="http://www.w3.org/1998/Math/MathML"
19
xmlns:db="http://docbook.org/ns/docbook">
22
<refname>Variable dimension (Scilab gateway)</refname>
25
How to get the dimensions of an argument or a variable stored as matrix.
29
<title>Calling Sequence</title>
30
<para>Input argument profile:</para>
31
<synopsis>SciErr getVarDimension(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols)</synopsis>
32
<para>Named variable profile:</para>
33
<synopsis>SciErr getNamedVarDimension(void* _pvCtx, char *_pstName, int* _piRows, int* _piCols)</synopsis>
36
<title>Parameters</title>
42
Scilab environment pointer, pass in "pvApiCtx" provided by api_scilab.h
47
<term>_piAddress</term>
50
The address of the variable.
66
Return number of rows.
74
Return number of columns.
82
Error structure where is stored errors messages history and first error number.
89
<title>Description</title>
90
<para>This help describes how to get the dimensions of a variable in a gateway.</para>
93
<!--File_gateway: SCI/modules/api_scilab/tests/unit_tests/common_function_api.c-->
94
<!--File_scilab: SCI/modules/api_scilab/tests/unit_tests/common_function.tst-->
95
<!--Lib_name: common_function-->
96
<!--Func_list: common_function-->
97
<title>Gateway Source</title>
98
<programlisting role="code_gateway">
100
SciErr printf_info(int _iVar);
102
int common_function(char *fname,unsigned long fname_len)
109
for(i = 0 ; i < Rhs ; i++)
111
sciErr = printf_info(i + 1);
114
printError(&sciErr, 0);
120
//1 for true, 0 for false
121
iBool = sciErr.iErr == 0 ? 1 : 0;
122
sciErr = createMatrixOfBoolean(pvApiCtx, 1, 1, 1, &iBool);
125
printError(&sciErr, 0);
128
//assign allocated variables to Lhs position
134
SciErr printf_info(int _iVar)
144
sciErr = getVarAddressFromPosition(pvApiCtx, _iVar, &piAddr);
150
sciprint("Variable %d information:\n", _iVar);
152
sciErr = getVarType(pvApiCtx, piAddr, &iType);
158
sciprint("\tType: ");
162
sciprint("double\n");
165
sciprint("polynomial\n");
168
sciprint("boolean\n");
171
sciprint("sparse\n");
173
case sci_boolean_sparse :
174
sciprint("boolean_sparse\n");
178
char pstSigned[] = "signed";
179
char pstUnsigned[] = "unsigned";
180
char* pstSign = pstSigned;
183
sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddr, &iPrec);
191
pstSign = pstUnsigned;
194
sciprint("%s integer %d bits\n", pstSign, (iPrec % 10) * 8);
198
sciprint("strings\n");
210
sciprint("Not manage by this function\n");
214
if(isVarComplex(pvApiCtx, piAddr))
216
sciprint("\tComplex: Yes\n");
219
sciprint("\tDimensions: ");
220
if(isVarMatrixType(pvApiCtx, piAddr))
222
sciErr = getVarDimension(pvApiCtx, piAddr, &iRows, &iCols);
228
sciprint("%d x %d", iRows, iCols);
232
sciErr = getListItemNumber(pvApiCtx, piAddr, &iItem);
237
sciprint("%d", iItem);
245
<title>Scilab test script</title>
246
<programlisting role="code_scilab"><![CDATA[
247
l1 = [1,2*%i,3;%i,2,3*%i];
248
l2 = ["may","the";"puffin","be";"with","you"];
250
l4 = uint16([1000,2000,3000]);
252
l = list(l1,l2,l3,l4,l5);
253
common_function(l(1:$))