* Bug #10523 fixed - The fact that flipdim could manage complex matrices was 41/5941/2
Sylvestre Ledru [Mon, 16 Jan 2012 15:45:06 +0000 (16:45 +0100)]
                     not clearly stated in the documentation.

Change-Id: I377e244a509f5aeea4de5408614e614894bc548b

scilab/CHANGES_5.4.X
scilab/modules/elementary_functions/help/en_US/matrixmanipulation/flipdim.xml
scilab/modules/elementary_functions/tests/unit_tests/flipdim.dia.ref [new file with mode: 0644]
scilab/modules/elementary_functions/tests/unit_tests/flipdim.tst [new file with mode: 0644]

index dd965f0..aaf877b 100644 (file)
@@ -236,6 +236,9 @@ Bug fixes
 
 * Bug #10521 fixed - frexp returned an wrong error message.
 
+* Bug #10523 fixed - The fact that flipdim could manage complex matrices was
+                     not clearly stated in the documentation.
+
 * Bug #10526 fixed - A string was in French in the English help page of cumprod.
 
 * Bug #10532 fixed - In some rare cases, browsevar crashed with some rare
index 9dbf763..532bcfe 100644 (file)
   <info>
     <pubdate>$LastChangedDate$</pubdate>
   </info>
-
+  
   <refnamediv>
     <refname>flipdim</refname>
-
+    
     <refpurpose>flip x components along a given dimension</refpurpose>
   </refnamediv>
-
+  
   <refsynopsisdiv>
     <title>Calling Sequence</title>
-
+    
     <synopsis>y=flipdim(x,dim)</synopsis>
   </refsynopsisdiv>
-
+  
   <refsection>
     <title>Arguments</title>
-
+    
     <variablelist>
       <varlistentry>
         <term>x</term>
-
+        
         <listitem>
-          <para>a scalar, a vector or an array of reals</para>
+          <para>a scalar, a vector or an array of real or complex numbers.</para>
         </listitem>
       </varlistentry>
-
+      
       <varlistentry>
         <term>dim</term>
-
+        
         <listitem>
           <para>a positive integer</para>
         </listitem>
       </varlistentry>
-
+      
       <varlistentry>
         <term>y</term>
-
+        
         <listitem>
           <para>a scalar, a vector or an array of reals</para>
         </listitem>
       </varlistentry>
     </variablelist>
   </refsection>
-
+  
   <refsection>
     <title>Description</title>
-
-    <para>Given <literal>x</literal>, a scalar/vector/array of reals and
-    <literal>dim</literal> a positive integer, this function flips the x
-    components along the dimension number <literal>dim</literal> of
-    <literal>x</literal> (<literal>x</literal> and <literal>y</literal> have
-    the same size)</para>
+    
+    <para>
+      Given <literal>x</literal>, a scalar/vector/array of real or complex numbers and
+      <literal>dim</literal> a positive integer, this function flips the x
+      components along the dimension number <literal>dim</literal> of
+      <literal>x</literal> (<literal>x</literal> and <literal>y</literal> have
+      the same size)
+    </para>
   </refsection>
-
+  
   <refsection>
     <title>Examples</title>
-
+    
     <programlisting role="example"><![CDATA[ 
 // example 1: flip x components along the first dimension
 x=[1 2 3 4; 5 6 7 8];
@@ -90,12 +92,18 @@ y=flipdim(x,dim)
 x=matrix(1:48,[3 2,4,2]);
 dim=3;
 y=flipdim(x,dim)
+
+// Example 4: the first example with complex
+x=[1+%i 2*%i 3 4; 5 6-%i 7 8*%pi*%i];
+dim=1;
+y=flipdim(x,dim)
+
  ]]></programlisting>
   </refsection>
-
+  
   <refsection>
     <title>Authors</title>
-
+    
     <para>F.Belahcene</para>
   </refsection>
 </refentry>
diff --git a/scilab/modules/elementary_functions/tests/unit_tests/flipdim.dia.ref b/scilab/modules/elementary_functions/tests/unit_tests/flipdim.dia.ref
new file mode 100644 (file)
index 0000000..4522dac
--- /dev/null
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Sylvestre Ledru
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+x=[1 2 3 4; 5 6 7 8];
+dim=1;
+y=flipdim(x,dim);
+assert_checkequal([5,6,7,8;1,2,3,4],y);
+dim=2;
+y=flipdim(x,dim);
+assert_checkequal([4,3,2,1;8,7,6,5],y);
+x=matrix(1:48,[3 2,4,2]);
+dim=3;
+ref=mlist(["hm","dims","entries"],int32([3,2,4,2]),[19;20;21;22;23;24;13;14;15;16;17;18;7;8;9;10;11;12;1;2;3;4;5;6;43;44;45;46;47;48;37;38;39;40;41;42;31;32;33;34;35;36;25;26;27;28;29;30]);
+y=flipdim(x,dim);
+assert_checkequal(y,ref);
+x=[1+%i 2*%i 3 4; 5 6-%i 7 8*%pi*%i];
+dim=1;
+y=flipdim(x,dim);
+ref=[ 5, 6-%i, 7,%i*25.132741;1+%i,%i*2, 3, 4];
+assert_checkalmostequal(y,ref);
diff --git a/scilab/modules/elementary_functions/tests/unit_tests/flipdim.tst b/scilab/modules/elementary_functions/tests/unit_tests/flipdim.tst
new file mode 100644 (file)
index 0000000..8e07e4f
--- /dev/null
@@ -0,0 +1,26 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Sylvestre Ledru
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+x=[1 2 3 4; 5 6 7 8];
+dim=1;
+y=flipdim(x,dim);
+assert_checkequal([5,6,7,8;1,2,3,4],y);
+
+dim=2;
+y=flipdim(x,dim);
+assert_checkequal([4,3,2,1;8,7,6,5],y);
+
+x=matrix(1:48,[3 2,4,2]);
+dim=3;
+ref=mlist(["hm","dims","entries"],int32([3,2,4,2]),[19;20;21;22;23;24;13;14;15;16;17;18;7;8;9;10;11;12;1;2;3;4;5;6;43;44;45;46;47;48;37;38;39;40;41;42;31;32;33;34;35;36;25;26;27;28;29;30]);
+y=flipdim(x,dim);
+assert_checkequal(y,ref);
+
+x=[1+%i 2*%i 3 4; 5 6-%i 7 8*%pi*%i];
+dim=1;
+y=flipdim(x,dim);
+ref=[ 5, 6-%i, 7,%i*25.132741;1+%i,%i*2, 3, 4];
+assert_checkalmostequal(y,ref);