License Header change: Removed the LICENSE_END before beta
[scilab.git] / scilab / modules / api_scilab / help / ja_JP / legacy / low_level_functions / double_reading_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  * Copyright (C) 2012 - 2016 - Scilab Enterprises
7  *
8  * This file is hereby licensed under the terms of the GNU GPL v2.0,
9  * pursuant to article 5.3.4 of the CeCILL v.2.1.
10  * This file was originally licensed under the terms of the CeCILL v2.1,
11  * and continues to be available under such terms.
12  * For more information, see the COPYING file which you should have received
13  * along with this program.
14  *
15  -->
16 <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="Double_management_reading_API" xml:lang="ja">
17     <refnamediv>
18         <refname>doubleの読み込み (Scilabゲートウェイ)</refname>
19         <refpurpose>
20             ゲートウェイ内でdoubleの行列を読み込む方法.
21         </refpurpose>
22     </refnamediv>
23     <refsynopsisdiv>
24         <title>呼び出し手順</title>
25         <para>入力引数プロファイル:</para>
26         <synopsis>SciErr getMatrixOfDouble(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, double** _pdblReal)</synopsis>
27         <synopsis>SciErr getComplexMatrixOfDouble(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, double** _pdblReal, double** _pdblImg)</synopsis>
28         <para>名前指定変数プロファイル:</para>
29         <synopsis>SciErr readNamedMatrixOfDouble(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, double* _pdblReal)</synopsis>
30         <synopsis>SciErr readNamedComplexMatrixOfDouble(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, double* _pdblReal, double* _pdblImg)</synopsis>
31     </refsynopsisdiv>
32     <refsection>
33         <title>引数</title>
34         <variablelist>
35             <varlistentry>
36                 <term>_pvCtx</term>
37                 <listitem>
38                     <para>
39                         Scilab環境ポインタ, api_scilab.hで定義される "pvApiCtx" を指定
40                     </para>
41                 </listitem>
42             </varlistentry>
43             <varlistentry>
44                 <term>_piAddress</term>
45                 <listitem>
46                     <para>
47                         Scilab変数のアドレス.
48                     </para>
49                 </listitem>
50             </varlistentry>
51             <varlistentry>
52                 <term>_pstName</term>
53                 <listitem>
54                     <para>
55                         "名前指定"関数の変数名.
56                     </para>
57                 </listitem>
58             </varlistentry>
59             <varlistentry>
60                 <term>_piRows</term>
61                 <listitem>
62                     <para>
63                         返される行数.
64                     </para>
65                 </listitem>
66             </varlistentry>
67             <varlistentry>
68                 <term>_piCols</term>
69                 <listitem>
70                     <para>
71                         返される列数.
72                     </para>
73                 </listitem>
74             </varlistentry>
75             <varlistentry>
76                 <term>_pdblReal</term>
77                 <listitem>
78                     <para>
79                         返される実数データ配列のアドレス (大きさ: _iCols * _iRows).
80                         "名前指定" 関数の場合, _pdblReal は関数コール前にメモリを確保しておく必要があります.
81                     </para>
82                 </listitem>
83             </varlistentry>
84             <varlistentry>
85                 <term>_pdblImg</term>
86                 <listitem>
87                     Return address of imaginary data array (size: _iCols * _iRows).
88                     For "Named" function, _pdblImg must be allocated before calling function.
89                 </listitem>
90             </varlistentry>
91             <varlistentry>
92                 <term>SciErr</term>
93                 <listitem>
94                     <para>
95                         エラー構造体で,エラーメッセージ履歴と最初のエラー番号を保持します.
96                     </para>
97                 </listitem>
98             </varlistentry>
99         </variablelist>
100     </refsection>
101     <refsection>
102         <title>説明</title>
103         <para>このヘルプはdoubleの行列をScilab APIにより処理する方法を示します.</para>
104     </refsection>
105     <refsection>
106         <!--File_gateway: SCI/modules/api_scilab/tests/unit_tests/double_reading_api.c-->
107         <!--File_scilab: SCI/modules/api_scilab/tests/unit_tests/double_reading_api.tst-->
108         <!--Lib_name: double_reading-->
109         <!--Func_list: read_double-->
110         <title>ゲートウェイのソース</title>
111         <programlisting role="code_gateway"><![CDATA[ 
112 #include "api_scilab.h"
113 int read_double(char *fname,void* pvApiCtx)
114 {
115         SciErr sciErr;
116         int i;
117         // 最初の変数の情報 : doubleの実数行列
118         int iType                       = 0;
119         int iRows                       = 0;
120         int iCols                       = 0;
121         int iComplex            = 0;
122         int *piAddr                     = NULL;
123         double* pdblReal        = NULL;
124         double* pdblImg         = NULL;
125         // 入力/出力引数を確認
126     CheckInputArgument(pvApiCtx, 1, 1);
127     CheckOutputArgument(pvApiCtx, 1, 1);
128     /************************
129         *    最初の変数    *
130         ************************/
131         // 最初の引数の変数アドレスを取得
132         sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
133         if(sciErr.iErr)
134         {
135                 printError(&sciErr, 0);
136                 return 0;
137         }
138         // 型を確認
139         sciErr = getVarType(pvApiCtx, piAddr, &iType);
140         if(sciErr.iErr || iType != sci_matrix)
141         {
142                 printError(&sciErr, 0);
143                 return 0;
144         }
145         // 複素数かどうかを取得
146         iComplex        = isVarComplex(pvApiCtx, piAddr);
147         // 複素数かどうかを確認
148         if(iComplex)
149         {
150                 // Scilabメモリから大きさとデータを取得
151                 sciErr = getComplexMatrixOfDouble(pvApiCtx, piAddr, &iRows, &iCols, &pdblReal, &pdblImg);
152         }
153         else
154         {
155                 // Scilabメモリから大きさとデータを取得
156                 sciErr = getMatrixOfDouble(pvApiCtx, piAddr, &iRows, &iCols, &pdblReal);
157         }
158         if(sciErr.iErr)
159         {
160                 printError(&sciErr, 0);
161                 return 0;
162         }
163         // データを用いて処理を行う
164         // 変数が複素数の場合,実部と虚部を交換し,それ以外は-1を乗じる
165         if(iComplex)
166         {
167                 sciErr = createComplexMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows, iCols, pdblImg, pdblReal);
168         }
169         else
170         {
171                 for(i = 0 ; i < iRows * iCols ; i++)
172                 {
173                         pdblReal[i] = pdblReal[i] * -1;
174                 }
175                 sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows, iCols, pdblReal);
176         }
177         if(sciErr.iErr)
178         {
179                 printError(&sciErr, 0);
180                 return 0;
181         }
182     AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
183         return 0;
184 }
185  ]]></programlisting>
186     </refsection>
187     <refsection>
188         <title>Scilab テストスクリプト</title>
189         <programlisting role="code_scilab"><![CDATA[ 
190 a = [   0 1 2 3; ..
191         4 5 6 7; ..
192         8 9 10 11];
193 b = [   23*%i,      1+22*%i,    2+21*%i,    3+20*%i,    4+19*%i,    5+18*%i; ..
194         6+17*%i,    7+16*%i,    8+15*%i,    9+14*%i,     10+13*%i,  11+12*%i; ..
195         12+11*%i,   13+10*%i,   14+9*%i,    15+8*%i,    16+7*%i,    17+6*%i; ..
196         18+5*%i,    19+4*%i,    20+3*%i,    21+2*%i,    22+1*%i,    23];
197 a2 = read_double(a);
198 b2 = read_double(b);
199 if or(a2 <> a * -1) then error("failed"), end
200 if or(b2 <> (imag(b) + real(b) * %i)) then error("failed"), end
201  ]]></programlisting>
202     </refsection>
203 </refentry>