rewrite hypermat api for scilab 6
[scilab.git] / scilab / modules / api_scilab / help / ja_JP / hypermat / C_getHypermatOfInt.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) 2013  - Scilab Enterprises - Calixte DENIZET
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.1-en.txt
11  *
12  -->
13 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="getHypermatOfInt" xml:lang="ja">
14     <refnamediv>
15         <refname>getHypermatOfInt</refname>
16         <refpurpose>
17             整数変数のハイパー行列を取得.
18         </refpurpose>
19     </refnamediv>
20     <refsynopsisdiv>
21         <title>呼び出し手順</title>
22         <synopsis>SciErr getHypermatOfInt8(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, char* _pcData)</synopsis>
23         <synopsis>SciErr getHypermatOfUnsignedInt8(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, unsigned char* _pucData)</synopsis>
24         <synopsis>SciErr getHypermatOfInt16(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, short* _psData)</synopsis>
25         <synopsis>SciErr getHypermatOfUnsignedInt16(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, unsigned short* _pusData)</synopsis>
26         <synopsis>SciErr getHypermatOfInt32(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, int* _piData)</synopsis>
27         <synopsis>SciErr getHypermatOfUnsignedInt32(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, unsigned int* _puiData)</synopsis>
28     </refsynopsisdiv>
29     <refsection>
30         <title>引数</title>
31         <variablelist>
32             <varlistentry>
33                 <term>_pvCtx</term>
34                 <listitem>
35                     <para>
36                         Scilab環境ポインタ, api_scilab.h により定義された "pvApiCtx"で指定.
37                     </para>
38                 </listitem>
39             </varlistentry>
40             <varlistentry>
41                 <term>_piAddress</term>
42                 <listitem>
43                     <para>
44                         Scilab変数のアドレス.
45                     </para>
46                 </listitem>
47             </varlistentry>
48             <varlistentry>
49                 <term>_dims</term>
50                 <listitem>
51                     <para>
52                         ハイパー行列の次元.
53                     </para>
54                 </listitem>
55             </varlistentry>
56             <varlistentry>
57                 <term>_ndims</term>
58                 <listitem>
59                     <para>
60                         次元の数.
61                     </para>
62                 </listitem>
63             </varlistentry>
64             <varlistentry>
65                 <term>_p*Data</term>
66                 <listitem>
67                     <para>
68                         データ.
69                     </para>
70                 </listitem>
71             </varlistentry>
72         </variablelist>
73     </refsection>
74     <refsection>
75         <title>戻り値</title>
76         <para>SciErr構造体, フィールド iErr は
77             エラー番号を保持します (エラーがない場合は 0).
78         </para>
79     </refsection>
80     <refsection>
81         <title>ゲートウェイのソース</title>
82         <programlisting role="code_gateway">
83             <![CDATA[ 
84 #include "api_scilab.h"
85 #include "localization.h"
86
87 int hypermatIntExample(char *fname,void* pvApiCtx)
88 {
89     SciErr sciErr;
90     int* piAddr = NULL;
91     int iType   = 0;
92     int iRet    = 0;
93     CheckInputArgument(pvApiCtx, 1, 1);
94     CheckOutputArgument(pvApiCtx, 0, 1);
95     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
96     if (sciErr.iErr)
97     {
98         printError(&sciErr, 0);
99         return 0;
100     }
101     if (isEmptyMatrix(pvApiCtx, piAddr))
102     {
103         iRet = createEmptyMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1);
104         if (iRet)
105         {
106             return iRet;
107         }
108         AssignOutputVariable(pvApiCtx, 1) = 0;
109     }
110     else if (isHypermatType(pvApiCtx, piAddr))
111     {
112         int * dims = NULL;
113         int ndims;
114         void * data = NULL;
115         int htype = 0;
116         int precision;
117         sciErr = getHypermatType(pvApiCtx, piAddr, &htype);
118         if (sciErr.iErr)
119         {
120             printError(&sciErr, 0);
121             return sciErr.iErr;
122         }
123         if (htype == sci_ints)
124         {
125             sciErr = getHypermatOfIntegerPrecision(pvApiCtx, piAddr, &precision);
126             if (sciErr.iErr)
127             {
128                 printError(&sciErr, 0);
129                 return sciErr.iErr;
130             }
131             switch (precision)
132             {
133             case SCI_INT8:
134                 sciErr = getHypermatOfInteger8(pvApiCtx, piAddr, &dims, &ndims, (char*)&data);
135                 if(sciErr.iErr)
136                 {
137                     printError(&sciErr, 0);
138                     return sciErr.iErr;
139                 }
140                 sciErr = createHypermatOfInteger8(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const char*)data);
141                 if (sciErr.iErr)
142                 {
143                     printError(&sciErr, 0);
144                     return sciErr.iErr;
145                 }
146                 break;
147             case SCI_UINT8:
148                 sciErr = getHypermatOfUnsignedInteger8(pvApiCtx, piAddr, &dims, &ndims, (unsigned char*)&data);
149                 if(sciErr.iErr)
150                 {
151                     printError(&sciErr, 0);
152                     return sciErr.iErr;
153                 }
154                 sciErr = createHypermatOfUnsignedInteger8(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned char*)data);
155                 if (sciErr.iErr)
156                 {
157                     printError(&sciErr, 0);
158                     return sciErr.iErr;
159                 }
160                 break;
161             case SCI_INT16:
162                 sciErr = getHypermatOfInteger16(pvApiCtx, piAddr, &dims, &ndims, (short*)&data);
163                 if(sciErr.iErr)
164                 {
165                     printError(&sciErr, 0);
166                     return sciErr.iErr;
167                 }
168                 sciErr = createHypermatOfInteger16(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const short*)data);
169                 if (sciErr.iErr)
170                 {
171                     printError(&sciErr, 0);
172                     return sciErr.iErr;
173                 }
174                 break;
175             case SCI_UINT16:
176                 sciErr = getHypermatOfUnsignedInteger16(pvApiCtx, piAddr, &dims, &ndims, (unsigned short*)&data);
177                 if(sciErr.iErr)
178                 {
179                     printError(&sciErr, 0);
180                     return sciErr.iErr;
181                 }
182                 sciErr = createHypermatOfUnsignedInteger16(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned short*)data);
183                 if (sciErr.iErr)
184                 {
185                     printError(&sciErr, 0);
186                     return sciErr.iErr;
187                 }
188                 break;
189             case SCI_INT32:
190                 sciErr = getHypermatOfInteger32(pvApiCtx, piAddr, &dims, &ndims, (int*)&data);
191                 if(sciErr.iErr)
192                 {
193                     printError(&sciErr, 0);
194                     return sciErr.iErr;
195                 }
196                 sciErr = createHypermatOfInteger32(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const int*)data);
197                 if (sciErr.iErr)
198                 {
199                     printError(&sciErr, 0);
200                     return sciErr.iErr;
201                 }
202                 break;
203             case SCI_UINT32:
204                 sciErr = getHypermatOfUnsignedInteger32(pvApiCtx, piAddr, &dims, &ndims, (unsigned int*)&data);
205                 if(sciErr.iErr)
206                 {
207                     printError(&sciErr, 0);
208                     return sciErr.iErr;
209                 }
210                 sciErr = createHypermatOfUnsignedInteger32(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned int*)data);
211                 if (sciErr.iErr)
212                 {
213                     printError(&sciErr, 0);
214                     return sciErr.iErr;
215                 }
216                 break;
217             }
218             case SCI_INT64:
219                 sciErr = getHypermatOfInteger64(pvApiCtx, piAddr, &dims, &ndims, (long long*)&data);
220                 if (sciErr.iErr)
221                 {
222                     printError(&sciErr, 0);
223                     return sciErr.iErr;
224                 }
225
226                 sciErr = createHypermatOfInteger64(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const long long*)data);
227                 if (sciErr.iErr)
228                 {
229                     printError(&sciErr, 0);
230                     return sciErr.iErr;
231                 }
232                 break;
233             case SCI_UINT64:
234                 sciErr = getHypermatOfUnsignedInteger64(pvApiCtx, piAddr, &dims, &ndims, (unsigned long long*)&data);
235                 if (sciErr.iErr)
236                 {
237                     printError(&sciErr, 0);
238                     return sciErr.iErr;
239                 }
240
241                 sciErr = createHypermatOfUnsignedInteger64(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned long long*)data);
242                 if (sciErr.iErr)
243                 {
244                     printError(&sciErr, 0);
245                     return sciErr.iErr;
246                 }
247                 break;
248             }
249         }
250         else
251         {
252             Scierror(999, _("%s: Wrong type for input argument #%d: An integer expected.\n"), fname, 1);
253             return 1;
254         }
255         AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
256     }
257     return 0;
258 }]]>
259         </programlisting>
260     </refsection>
261     <refsection>
262         <title>Scilab テストスクリプト</title>
263         <programlisting role="code_scilab"><![CDATA[ 
264 a = hypermat([1 2 3], int8(1:6));
265 b = hypermat([1 2 3], uint8(1:6));
266 c = hypermat([1 2 3], int16(1:6));
267 d = hypermat([1 2 3], uint16(1:6));
268 e = hypermat([1 2 3], int32(1:6));
269 f = hypermat([1 2 3], uint32(1:6));
270 hypermatExampleInt(a) == a
271 hypermatExampleInt(b) == b
272 hypermatExampleInt(c) == c
273 hypermatExampleInt(d) == d
274 hypermatExampleInt(e) == e
275 hypermatExampleInt(f) == f
276  ]]></programlisting>
277     </refsection>
278 </refentry>