Elementary function: move ndgrid to the right place after 6ad9efdc
[scilab.git] / scilab / modules / elementary_functions / help / ja_JP / elementarymatrices / ndgrid.xml
index 11b79d3..1d5fc05 100644 (file)
 <?xml version="1.0" encoding="UTF-8"?>
 
 <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="ndgrid" xml:lang="ja">
+
+<refnamediv>
     
-    <refnamediv>
-        
-        <refname>ndgrid</refname>
-        
-        <refpurpose>
-            
-            多次元関数評価用グリッドの配列
-            
-        </refpurpose>
+    <refname>ndgrid</refname>
+    
+    <refpurpose>与えられたベクトルを複製することによって、行列またはN次元配列を作成
         
-    </refnamediv>
+    </refpurpose>
     
-    <refsynopsisdiv>
+</refnamediv>
+
+<refsynopsisdiv>
+    
+    <title>呼び出し手順</title>
+    
+    <synopsis>[X, Y] = ndgrid(x,y)
         
-        <title>呼び出し手順</title>
+        [X, Y, Z] = ndgrid(x,y,z)
         
-        <synopsis>[X, Y] = ndgrid(x,y)
-            
-            [X, Y, Z] = ndgrid(x,y,z)
-            
-            [X, Y, Z, T] = ndgrid(x,y,z,t)
-            
-            [X1, X2, ..., Xm] = ndgrid(x1,x2,...,xm)
-            
-        </synopsis>
+        [X, Y, Z, T] = ndgrid(x,y,z,t)
         
-    </refsynopsisdiv>
-    
-    <refsection>
+        [X1, X2, ..., Xm] = ndgrid(x1,x2,...,xm)
         
-        <title>引数</title>
+    </synopsis>
+    
+</refsynopsisdiv>
+
+<refsection role="arguments">
+    
+    <title>引数</title>
+    
+    <variablelist>
         
-        <variablelist>
+        <varlistentry>
             
-            <varlistentry>
-                
-                <term>x, y, z, ...</term>
-                
-                <listitem>
-                    
-                    <para>ベクトル</para>
-                    
-                </listitem>
-                
-            </varlistentry>
+            <term>x, y, z, ...</term>
             
-            <varlistentry>
+            <listitem>
                 
-                <term>X, Y, Z, ...</term>
+                <para>vectors of any data types. They may have distinct data types.</para>
                 
+            </listitem>
+            
+        </varlistentry>
+        
+        <varlistentry>
+            
+            <term>X, Y, Z, ...</term>
+            
                 <listitem>
-                    
-                    <para>
+                    <para>Matrices in case of 2 input arguments, or hypermatrices otherwise.
                         
-                        入力引数が2個の場合は行列,
+                        They all have the same sizes: size(x,"*") rows, size(y,"*") columns,
                         
-                        それ以外の場合はハイパー行列
+                        size(z,"*") layers, etc.
+                  </para>
+                  <para>
+                        
+                        They have the datatypes of respective input vectors:
+                        
+                        <literal>typeof(X)==typeof(x)</literal>,
+                        
+                        <literal>typeof(Y)==typeof(y)</literal>, etc.
                         
                     </para>
                     
                 </listitem>
-                
-            </varlistentry>
-            
-        </variablelist>
+        </varlistentry>
         
-    </refsection>
+    </variablelist>
+    
+</refsection>
+
+<refsection role="description">
+    
+    <title>説明</title>
     
-    <refsection>
+    <para>
+        The first application of <function>ndgrid</function> is to build
         
-        <title>説明</title>
+        a grid of nodes meshing the 2D or 3D or N-D space according to 2, 3,
         
-        <para>
-            
-            この関数はユーティリティルーチンで,
-            
-            2, 3, ..., n次元のグリッド上で関数の評価を行う
-            
-            ための配列を作成する際に便利です.
-            
-            例えば, 2次元の場合, グリッドは
-            
-            長さ nx および nyの
-            
-            2つのベクトル
-            
-            <literal>x</literal> および <literal> y</literal>
-            
-            で定義され,
-            
-            <emphasis>i=1,..,nx</emphasis> および <emphasis>j=1,..,ny</emphasis>
-            
-            として,座標<emphasis>(x(i),y(j))</emphasis>となります.
-            
-            そのグリッド上で (例えば<emphasis>f</emphasis>のような)関数の評価を
-            
-            行うことになります.
-            
-            この場合,この関数は,以下のような大きさ<emphasis>nx x ny</emphasis>の
-            
-            2つの行列<literal>X,Y</literal>を計算します :
-            
-        </para>
+        or more sets
         
-        <programlisting role="no-scilab-exec"><![CDATA[ 
-X(i,j) = x(i)   for all i in [1,nx]
-Y(i,j) = y(j)       and j in [1,ny]
- ]]></programlisting>
+        <literal>x</literal>, <literal> y</literal>, etc.. of
         
-        <para>
-            
-            評価は,<literal>Z=f(X,Y)</literal>で行うことができます.
-            
-            (ベクトル引数で<literal>f</literal>を評価するようコードが
-            
-            作成されている場合,
-            
-            <literal>*</literal>,
-            
-            <literal>/</literal> および <literal>^</literal>の部分に
-            
-            要素毎の演算 <literal>.*</literal>, <literal>./</literal> および
-            
-            <literal>.^</literal>を使用することにより,(一般に)動作します..
-            
-        </para>
+        "template" coordinates sampled along each direction/dimension of the
         
-        <para>
-            
-            3次元の場合, 長さ nx, ny および nzの3個のベクトル<literal>x,y,z</literal>
-            
-            を指定し,
-            
-            <literal>X,Y,Z</literal>は以下のように大きさ
-            
-            <emphasis>nx x ny x nz</emphasis>のハイパー行列となります :
-            
-        </para>
+        space that you want to mesh.
         
-        <programlisting role="no-scilab-exec"><![CDATA[ 
-X(i,j,k) = x(i)  
-Y(i,j,k) = y(j)   for all (i,j,k) in [1,nx]x[1,ny]x[1,nz]
-Z(i,j,k) = z(k)
- ]]></programlisting>
+    </para>
+    
+    <para>
+        Hence, the matrix or hypermatrix <literal>X</literal> is made
+        
+        by replicating the vector <literal>x</literal> as all its columns;
+        
+        the matrix or hypermatrix <literal>Y</literal> is made
+        
+        by replicating the vector <literal>y</literal> as all its rows;
         
-        <para>
+        <literal>Z</literal> is made of replicating the vector
+        
+        <literal>z</literal> along all its local thicknesses (3rd dimension);
+        
+        etc
+        
+    </para>
+    
+    <screen>
+        
+        <![CDATA[--> [X, Y] = ndgrid([1 3 4], [0 2 4 6])
+ X  =
+   1.   1.   1.   1.
+   3.   3.   3.   3.
+   4.   4.   4.   4.
+
+   Y  =
+   0.   2.   4.   6.
+   0.   2.   4.   6.
+   0.   2.   4.   6.
+]]>
+    </screen>
+    
+    <para>
+        
+        Then, the coordinates of the node(i,j) in the 2D space
+        
+        will be
+        
+        simply <literal>[x(i), y(j)]</literal> equal to
+        
+        <literal>[X(i,j), Y(i,j)]</literal>. As well, the coordinates of a
+        
+        <literal>node(i,j,k)</literal> of a 3D grid will be
+        
+        <literal>[x(i), y(j), z(k)]</literal> equal to
+        
+        <literal>[X(i,j,k), Y(i,j,k), Z(i,j,k)]</literal>.
+        
+    </para>
+    
+    <para>
+        
+        This replication scheme can be generalized to any number of dimensions,
+        
+        as well to any type of uniform data. Let's for instance consider 2
+        
+        attributes:
+        
+        <orderedlist>
             
-            一般的な場合, m 個の入力引数<literal>x1, x2, ..,
+            <listitem>The first is a number, to be chosen from the vector say
                 
-                xm
+                <literal>n = [ 3 7 ]</literal>
                 
-            </literal>
-            
-            ,それから m個の出力引数
+            </listitem>
             
-            <literal>X1, X2, .., Xm</literal> は以下のような
-            
-            大きさ <emphasis>nx1 x nx2 x ... x
+            <listitem>The second is a letter, to be chosen from the vector
                 
-                nxm
+                say <literal>c = ["a" "e" "i" "o" "u" "y"]</literal>
                 
-            </emphasis>
-            
-            のハイパー行列となります :
+            </listitem>
             
-        </para>
+        </orderedlist>
         
-        <programlisting role="no-scilab-exec"><![CDATA[ 
-Xj(i1,i2,...,ij,...,im) = xj(ij)   
-for all (i1,i2,...,im) in [1,nx1]x[1,nx2]x...x[1,nxm]  
- ]]></programlisting>
+        Then we want to build the set of all {n,c} possible pairs. It will
+        
+        just be the 2D grid:
+        
+    </para>
+    
+    <screen>
+        
+        <![CDATA[--> [N, C] = ndgrid([3 7],["a" "e" "i" "o" "u" "y"])
+ C  = 
+!a  e  i  o  u  y  !
+!a  e  i  o  u  y  !
+
+ N  = 
+   3.   3.   3.   3.   3.   3.
+   7.   7.   7.   7.   7.   7.
+]]>
+    </screen>
+    
+    <para>Then, the object(i,j) will have the properties
+        
+        <literal>{n(i) c(j)}</literal> that now can be addressed with
+        
+        <literal>{N(i,j) C(i,j)}</literal>.
         
-    </refsection>
+        This kind of grid may be useful to initialize an array of structures.
+        
+    </para>
     
-    <refsection>
+    <para>
+        Following examples show how to use <varname>X, Y, Z</varname> in
         
-        <title>例</title>
+        most frequent applications.
         
-        <programlisting role="example"><![CDATA[  
-// 簡単な2次元グリッドを作
-nx = 40; ny = 40;
-x = linspace(-1,1,nx);
-y = linspace(-1,1,ny);
+    </para>
+     
+    
+</refsection>
+
+<refsection role="examples">
+    
+    <title>例</title>
+    
+    
+    
+    <para>
+        <emphasis role="bold">Example #1:</emphasis>
+    </para>
+    
+    <programlisting role="example"><![CDATA[
+// Create a simple 2d grid
+x = linspace(-10,2,40);
+y = linspace(-5,5,40);
 [X,Y] = ndgrid(x,y);
-// グリッド上で関数を計算してプロット
-//deff("z=f(x,y)","z=128*x.^2 .*(1-x).^2 .*y.^2 .*(1-y).^2");
-deff("z=f(x,y)","z=x.^2 + y.^3")
-Z = f(X,Y);
+
+// Compute ordinates Z(X,Y) on the {X, Y} grid and plot Z(X,Y)
+Z = X - 3*X.*sin(X).*cos(Y-4) ;
 clf()
-plot3d(x,y,Z, flag=[2 6 4]); show_window()
+plot3d(x,y,Z, flag=[color("green") 2 4], alpha=7, theta=60); show_window()
  ]]></programlisting>
+    
+    <scilab:image>
         
-        <scilab:image>
-            
-            nx = 40; ny = 40;
-            
-            x = linspace(-1,1,nx);
-            
-            y = linspace(-1,1,ny);
-            
-            [X,Y] = ndgrid(x,y);
-            
-            deff("z=f(x,y)","z=x.^2 + y.^3")
-            
-            Z = f(X,Y);
-            
-            plot3d(x,y,Z, flag=[2 6 4]);
-            
-        </scilab:image>
+        x = linspace(-10,2,40);
+        
+        y = linspace(-5,5,40);
+        
+        [X,Y] = ndgrid(x,y);
+        
+        Z = X - 3*X.*sin(X).*cos(Y-4) ;
         
-        <programlisting role="example"><![CDATA[
+        clf()
+        
+        plot3d(x,y,Z, flag=[color("green") 2 4], alpha=7, theta=60); show_window()
+        
+    </scilab:image>
+    
+    
+    
+    <para>
+        <emphasis role="bold">Example #2:</emphasis>
+    </para>
+    
+    <programlisting role="example"><![CDATA[
 // 簡単な3次元グリッドを作成
 nx = 10; ny = 6; nz = 4;
 x = linspace(0,2,nx);
@@ -232,73 +270,140 @@ for j=1:ny
    XF = [XF xf]; YF = [YF yf]; ZF = [ZF zf];
 end
 clf()
-plot3d(XF,YF,ZF, flag=[0 6 3], leg="X@Y@Z")
+plot3d(XF,YF,ZF, flag=[0 6 3], 66, 61, leg="X@Y@Z")
 xtitle("A 3d grid !"); show_window()
  ]]></programlisting>
+    
+    <scilab:image>
         
-        <scilab:image>
-            
-            nx = 10; ny = 6; nz = 4;
-            
-            x = linspace(0,2,nx);
-            
-            y = linspace(0,1,ny);
-            
-            z = linspace(0,0.5,nz);
-            
-            [X,Y,Z] = ndgrid(x,y,z);
-            
-            
-            
-            XF=[]; YF=[]; ZF=[];
-            
-            
-            
-            for k=1:nz
-            
-            [xf,yf,zf] = nf3d(X(:,:,k),Y(:,:,k),Z(:,:,k));
-            
-            XF = [XF xf]; YF = [YF yf]; ZF = [ZF zf];
-            
-            end
-            
+        nx = 10; ny = 6; nz = 4;
+        
+        x = linspace(0,2,nx);
+        
+        y = linspace(0,1,ny);
+        
+        z = linspace(0,0.5,nz);
+        
+        [X,Y,Z] = ndgrid(x,y,z);
+        
+        XF=[]; YF=[]; ZF=[];
+        
+        for k=1:nz
+        
+        [xf,yf,zf] = nf3d(X(:,:,k),Y(:,:,k),Z(:,:,k));
+        
+        XF = [XF xf]; YF = [YF yf]; ZF = [ZF zf];
+        
+        end
+        
+        for j=1:ny
+        
+        [xf,yf,zf] = nf3d(matrix(X(:,j,:),[nx,nz]),...
+        
+        matrix(Y(:,j,:),[nx,nz]),...
+        
+        matrix(Z(:,j,:),[nx,nz]));
+        
+        XF = [XF xf]; YF = [YF yf]; ZF = [ZF zf];
+        
+        end
+        
+        plot3d(XF,YF,ZF, flag=[0 6 3], 66, 61, leg="X@Y@Z")
+        
+        xtitle("A 3d grid !");
+        
+    </scilab:image>
+    
+    <para>
+        <emphasis role="bold">Example #3: Create a table of digrams:</emphasis>
+    </para>
+    
+    <programlisting role="example"><![CDATA[
+[c1, c2] = ndgrid(["a" "b" "c"], ["a" "b" "c" "d" "e" "f" "g" "h"])
+c1+c2
+ ]]></programlisting>
+    
+    <screen>
+        
+        <![CDATA[--> [c1, c2] = ndgrid(["a" "b" "c"], ["a" "b" "c" "d" "e" "f" "g" "h"])
+ c2  =
+!a  b  c  d  e  f  g  h  !
+!a  b  c  d  e  f  g  h  !
+!a  b  c  d  e  f  g  h  !
+
+ c1  =
+!a  a  a  a  a  a  a  a  !
+!b  b  b  b  b  b  b  b  !
+!c  c  c  c  c  c  c  c  !
+
+--> c1+c2
+ ans  =
+!aa  ab  ac  ad  ae  af  ag  ah  !
+!ba  bb  bc  bd  be  bf  bg  bh  !
+!ca  cb  cc  cd  ce  cf  cg  ch  !
+]]>
+    </screen>
+    
+</refsection>
+
+<refsection role="see also">
+    
+    <title>参照</title>
+    
+    <simplelist type="inline">
+        
+        <member>
             
+            <link linkend="meshgrid">meshgrid</link>
             
-            for j=1:ny
+        </member>
+        
+        <member>
             
-            [xf,yf,zf] = nf3d(matrix(X(:,j,:),[nx,nz]),...
+            <link linkend="kron">kron</link>
             
-            matrix(Y(:,j,:),[nx,nz]),...
+        </member>
+        
+        <member>
             
-            matrix(Z(:,j,:),[nx,nz]));
+            <link linkend="feval">feval</link>
             
-            XF = [XF xf]; YF = [YF yf]; ZF = [ZF zf];
+        </member>
+        
+        <member>
             
-            end
+            <link linkend="eval3d">eval3d</link>
             
-            plot3d(XF,YF,ZF, flag=[0 6 3], leg="X@Y@Z")
+        </member>
+        
+        <member>
             
-            xtitle("A 3d grid !"); 
+            <link linkend="nf3d">nf3d</link>
             
-        </scilab:image>
+        </member>
         
-    </refsection>
+    </simplelist>
     
-    <refsection role="see also">
-        
-        <title>参照</title>
+</refsection>
+
+<refsection role="history">
+    
+    <title>履歴</title>
+    
+    <revhistory>
         
-        <simplelist type="inline">
+        <revision>
             
-            <member>
-                
-                <link linkend="kron">kron</link>
+            <revnumber>6.0</revnumber>
+            
+            <revdescription>Extension to all homogeneous datatypes ([], booleans, encoded integers, polynomials, rationals, strings). Revision of the help page.
                 
-            </member>
+            </revdescription>
             
-        </simplelist>
+        </revision>
         
-    </refsection>
+    </revhistory>
     
-</refentry>
+</refsection>
 
+</refentry>