Revert "Update of messages"
[scilab.git] / scilab / modules / api_scilab / help / en_US / common_iscomplex_api.xml
1 <?xml version="1.0" encoding="utf-8"?>
2 <!--
3  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4  * Copyright (C) 2009  - DIGITEO - Antoine ELIAS
5  * 
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
11  *
12  -->
13 <refentry version="5.0-subset Scilab" xml:id="Common_iscomplex_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">
20
21     <refnamediv>
22         <refname>Variable Complexity (Scilab gateway)</refname>
23
24         <refpurpose>
25             How to get variable complexity.
26         </refpurpose>
27     </refnamediv>
28     <refsynopsisdiv>
29       <title>Calling Sequence</title>
30       <synopsis>int isVarComplex(int* _piAddress)</synopsis>
31     </refsynopsisdiv>
32     <refsection>
33         <title>Parameters</title>
34         <variablelist>
35             <varlistentry>
36                 <term>_piAddress</term>
37                 <listitem>
38                     <para>
39                         Address of the variable
40                     </para>
41                 </listitem>
42             </varlistentry>
43             <varlistentry>
44                 <term>Returned value</term>
45                 <listitem>
46                     <para>
47                         0 for real variables and 1 for complex variables.
48                     </para>
49                 </listitem>
50             </varlistentry>
51         </variablelist>
52     </refsection>
53     <refsection>
54       <title>Description</title>
55       <para>This help describes how to retrieve variable complexity.</para>
56     </refsection>
57     <refsection>
58         <!--File_gateway: SCI/modules/core/tests/unit_tests/commom_function_api.c-->
59         <!--File_scilab: SCI/modules/core/tests/unit_tests/commom_function.tst-->
60         <!--Lib_name: commom_function-->
61         <!--Func_list: commom_function-->
62         <title>Gateway Source</title>
63         <programlisting role="code_gateway">
64             <![CDATA[
65 int printf_info(int _iVar);
66
67 int commom_function(char *fname,unsigned long fname_len)
68 {
69     int i;
70     int iRet        = 0;
71     int *piAddr1    = NULL;
72
73     for(i = 0 ; i < Rhs ; i++)
74     {
75         iRet = printf_info(i + 1);
76         if(iRet)
77         {
78             break;
79         }
80         sciprint("\n\n");
81     }
82
83     if(iRet)
84     {
85         //1 for true, 0 for false
86         iRet = !iRet;
87         createMatrixOfBoolean(1, 1, 1, &iRet);
88         //assign allocated variables to Lhs position
89         LhsVar(1) = 1;
90     }
91     else
92     {
93         //assign allocated variables to Lhs position
94         LhsVar(1) = 0;
95     }
96
97     return 0;
98 }
99
100 int printf_info(int _iVar)
101 {
102     int* piAddr     = NULL;
103     int iRet        = 0;
104     int iType       = 0;
105     int iRows       = 0;
106     int iCols       = 0;
107     int iItem       = 0;
108     int iComplex    = 0;
109
110     iRet = getVarAddressFromPosition(_iVar, &piAddr);
111     if(iRet)
112     {
113         return 1;
114     }
115
116     sciprint("Variable %d information:\n", _iVar);
117     iType = getVarType(piAddr);
118     sciprint("\tType: ");
119     switch(iType)
120     {
121         case sci_matrix : 
122             sciprint("double\n");
123             break;
124         case sci_poly : 
125             sciprint("polynomial\n");
126             break;
127         case sci_boolean : 
128            sciprint("boolean\n");
129            break;
130         case sci_sparse : 
131             sciprint("sparse\n");
132             break;
133         case sci_boolean_sparse : 
134             sciprint("boolean_sparse\n");
135             break;
136         case sci_ints : 
137         {
138             char pstSigned[]    = "signed";
139             char pstUnsigned[]  = "unsigned";
140             char* pstSign       = pstSigned;
141
142             int iPrec           = 0;
143             iRet = getMatrixOfIntegerPrecision(piAddr, &iPrec);
144
145             if(iPrec > 10)
146             {
147                 pstSign = pstUnsigned;
148             }
149
150             sciprint("%s integer %d bits\n", pstSign, (iPrec % 10) * 8);
151         }
152         break;
153         case sci_strings : 
154             sciprint("strings\n");
155             break;
156         case sci_list : 
157             sciprint("list\n");
158             break;
159         case sci_tlist : 
160             sciprint("tlist\n");
161             break;
162         case sci_mlist : 
163             sciprint("mlist\n");
164             break;
165         default :
166             sciprint("Not manage by this function\n");
167             return 0;
168     }
169
170     if(isVarComplex(piAddr))
171     {
172         sciprint("\tComplex: Yes\n");
173     }
174
175     sciprint("\tDimensions: ");
176     if(isVarMatrixType(piAddr))
177     {
178         getVarDimension(piAddr, &iRows, &iCols);
179         sciprint("%d x %d", iRows, iCols);
180     }
181     else
182     {
183         getListItemNumber(piAddr, &iItem);
184         sciprint("%d", iItem);
185     }
186     return 0;
187 }
188         ]]>
189         </programlisting>
190     </refsection>
191
192     <refsection>
193         <title>Scilab test script</title>
194         <programlisting role="code_scilab">
195             <![CDATA[
196 l1 = [1,2*%i,3;%i,2,3*%i];
197 l2 = ["may","the";"puffin","be";"with","you"];
198 l3 = int8([1,2,3]);
199 l4 = uint16([1000,2000,3000]);
200 l5 = list(l1,l2,l3);
201 l = list(l1,l2,l3,l4,l5);
202 commom_function(l(1:$))
203             ]]>
204         </programlisting>
205     </refsection>
206 </refentry>