bug 12449: QUANT_f quantization methods were not behaving properly. Clarified documen... 94/14094/4
Pierre-Aime Agnel [Fri, 21 Mar 2014 10:14:37 +0000 (11:14 +0100)]
Change-Id: I406ffee3e47969140bead4a856ee20e9dd83a852

15 files changed:
scilab/CHANGES_5.5.X
scilab/modules/helptools/etc/images_md5.txt
scilab/modules/helptools/images/QUANT_f_1.png [new file with mode: 0644]
scilab/modules/helptools/images/QUANT_f_2.png [new file with mode: 0644]
scilab/modules/helptools/images/QUANT_f_Example.zcos.png
scilab/modules/helptools/images/QUANT_f_Example_Quantization_Mode.zcos.png [new file with mode: 0644]
scilab/modules/helptools/images/_LaTeX_QUANT_f.xml_1.png [new file with mode: 0644]
scilab/modules/helptools/images/_LaTeX_QUANT_f.xml_2.png [new file with mode: 0644]
scilab/modules/scicos_blocks/src/fortran/qzcel.f
scilab/modules/scicos_blocks/src/fortran/qzflr.f
scilab/modules/scicos_blocks/src/fortran/qzrnd.f
scilab/modules/scicos_blocks/src/fortran/qztrn.f
scilab/modules/xcos/examples/signalprocessing_pal/QUANT_f_Example.zcos
scilab/modules/xcos/examples/signalprocessing_pal/QUANT_f_Example_Quantization_Mode.zcos [new file with mode: 0644]
scilab/modules/xcos/help/en_US/palettes/Signalprocessing_pal/QUANT_f.xml

index ca5d871..9e8ea9f 100644 (file)
@@ -1626,6 +1626,8 @@ Xcos Bug Fixes
 
 * Bug #12424 fixed - Calling lincos on a derivative block made Scilab crash.
 
+* Bug #12449 fixed - QUANT_f was not rounding/truncating/flooring/ceiling properly input signal.
+
 * Bug #12460 fixed - xcosPalGenerateAllIcons sometimes crashed Scilab.
 
 * Bug #12461 fixed - Cancelling zoom out by zooming in did not fully work.
index 1c73678..609ad90 100644 (file)
@@ -151,6 +151,8 @@ PID_1.png=8843194ddcc121e2029098a2cd9fd64b
 PID_2.png=ca84f21c8c54b33b1813441eec8f9f8f
 PID_3.png=388ad02b0483aeda88a8b41dcf37ef5c
 PlotSparse_1.png=89f28b0065018873360603a560d5f079
+QUANT_f_1.png=c2543a4ecacb4e8006e27b39de01d730
+QUANT_f_2.png=d014d30ed3d0745cc91b3cda699dbb14
 RAMP_1.png=c23fa5d3551bbd0d62ed522a383f858b
 REGISTER_1.png=b10b9eb56f4f302b40722fc37f90152
 SAWTOOTH_f_1.png=10ee1db52ca7bf5c9a88f6af721493a6
@@ -360,6 +362,8 @@ _LaTeX_JKFLIPFLOP_content.dbk_9.png=cfcd208495d565ef66e7dff9f98764da
 _LaTeX_LOGIC.xml_1.png=5eea457f4a5dfd27686eb033e0c9ae1
 _LaTeX_LOGIC.xml_fr_FR_1.png=c67df0b2be376db98ba6674c7c560b67
 _LaTeX_PerteDP.xml_1.png=aaa66cecfcbc25a73e52eb804020799
+_LaTeX_QUANT_f.xml_1.png=aad18c0a88969b4c1bdc3711475796c2
+_LaTeX_QUANT_f.xml_2.png=9ab0347369b93587a1fc8dbd6c6a8862
 _LaTeX_RAMP.xml_1.png=c851aba90cb36bc4a4d869245c01a167
 _LaTeX_READC_f.xml_1.png=17ffc102ccbc189e8e679cf183632620
 _LaTeX_READC_f.xml_2.png=ec71f47b6aee7b3cd545386b93601915
diff --git a/scilab/modules/helptools/images/QUANT_f_1.png b/scilab/modules/helptools/images/QUANT_f_1.png
new file mode 100644 (file)
index 0000000..a26f9c6
Binary files /dev/null and b/scilab/modules/helptools/images/QUANT_f_1.png differ
diff --git a/scilab/modules/helptools/images/QUANT_f_2.png b/scilab/modules/helptools/images/QUANT_f_2.png
new file mode 100644 (file)
index 0000000..a4e3ab1
Binary files /dev/null and b/scilab/modules/helptools/images/QUANT_f_2.png differ
index 21d0a5f..a849cd8 100644 (file)
Binary files a/scilab/modules/helptools/images/QUANT_f_Example.zcos.png and b/scilab/modules/helptools/images/QUANT_f_Example.zcos.png differ
diff --git a/scilab/modules/helptools/images/QUANT_f_Example_Quantization_Mode.zcos.png b/scilab/modules/helptools/images/QUANT_f_Example_Quantization_Mode.zcos.png
new file mode 100644 (file)
index 0000000..6d576aa
Binary files /dev/null and b/scilab/modules/helptools/images/QUANT_f_Example_Quantization_Mode.zcos.png differ
diff --git a/scilab/modules/helptools/images/_LaTeX_QUANT_f.xml_1.png b/scilab/modules/helptools/images/_LaTeX_QUANT_f.xml_1.png
new file mode 100644 (file)
index 0000000..ec2e61f
Binary files /dev/null and b/scilab/modules/helptools/images/_LaTeX_QUANT_f.xml_1.png differ
diff --git a/scilab/modules/helptools/images/_LaTeX_QUANT_f.xml_2.png b/scilab/modules/helptools/images/_LaTeX_QUANT_f.xml_2.png
new file mode 100644 (file)
index 0000000..c8c910c
Binary files /dev/null and b/scilab/modules/helptools/images/_LaTeX_QUANT_f.xml_2.png differ
index e4a1b44..4502387 100644 (file)
@@ -31,12 +31,23 @@ c
       double precision t,xd(*),x(*),z(*),tvec(*),rpar(*),u(*),y(*)
       integer flag,nevprt,nx,nz,ntvec,nrpar,ipar(*)
       integer nipar,nu,ny
+      double precision flr
 
 
       integer i
-c      
+c     Quantization by taking the nearest whole number of quantized steps
+c     towards infinity (ceiling)
       do 15 i=1,nu
-        y(i)=rpar(i)*ANINT(u(i)/rpar(i)-0.5d0)
+         flr=AINT(u(i)/rpar(i))
+         if (u(i).lt.0.0d0)then
+            y(i)=rpar(i)*flr
+         else
+            if (u(i).eq.flr)then
+               y(i)=rpar(i)*flr
+            else
+               y(i)=rpar(i)*(flr+1.0d0)
+            endif
+         endif
  15   continue
       return
 
index 4d3f797..59baeb3 100644 (file)
@@ -35,9 +35,14 @@ c
 
 
       integer i
-c
+c     Quantification by taking the nearest whole number of quantized steps
+c     towards minus infinity (floor)
       do 15 i=1,nu
-         y(i)=rpar(i)*ANINT(u(i)/rpar(i)+0.5d0)
+         if (u(i).lt.0.0d0)then
+            y(i)=rpar(i)*ANINT(u(i)/rpar(i)-0.5d0)
+         else
+            y(i)=rpar(i)*AINT(u(i)/rpar(i))
+         endif
  15   continue
       return
       end
index 3ce84a4..9e8290d 100644 (file)
@@ -34,13 +34,9 @@ c
 
 
       integer i
-c
+c     Quantization by rounding the number of quantized steps
       do 15 i=1,nu
-         if (u(i).lt.0.0d0)then
-            y(i)=rpar(i)*(ANINT(u(i)/rpar(i)+0.5d0)-0.5d0)
-         else
-            y(i)=rpar(i)*(ANINT(u(i)/rpar(i)-0.5d0)+0.5d0)
-         endif
+         y(i)=rpar(i)*ANINT(u(i)/rpar(i))
  15   continue
       return
       end
index 490a2c4..bc50b8d 100644 (file)
@@ -33,13 +33,9 @@ c
 
 
       integer i
-c
+c     Quantification by truncating the number of quantized steps
       do 15 i=1,nu
-         if (u(i).lt.0.0d0)then
-            y(i)=rpar(i)*(ANINT(u(i)/rpar(i)+0.5d0))
-         else
-            y(i)=rpar(i)*(ANINT(u(i)/rpar(i)-0.5d0))
-         endif  
+         y(i)=rpar(i)*AINT(u(i)/rpar(i))
  15   continue
 
       end
index 6d03938..4ab05cb 100644 (file)
Binary files a/scilab/modules/xcos/examples/signalprocessing_pal/QUANT_f_Example.zcos and b/scilab/modules/xcos/examples/signalprocessing_pal/QUANT_f_Example.zcos differ
diff --git a/scilab/modules/xcos/examples/signalprocessing_pal/QUANT_f_Example_Quantization_Mode.zcos b/scilab/modules/xcos/examples/signalprocessing_pal/QUANT_f_Example_Quantization_Mode.zcos
new file mode 100644 (file)
index 0000000..0b17fcd
Binary files /dev/null and b/scilab/modules/xcos/examples/signalprocessing_pal/QUANT_f_Example_Quantization_Mode.zcos differ
index cf27ff9..e749e61 100644 (file)
         <title>Description</title>
         <para>
             This block outputs the quantization of the input according to a choice
-            of methods:
+            of methods (quantization types):
         </para>
         <itemizedlist>
             <listitem>
                 <para>
                     <emphasis role="bold">1: Round</emphasis>
                 </para>
-                <para>Nearest whole number of the value at the first step</para>
+                <para>Rounding the number of quantization steps (output signal is the nearest step)</para>
             </listitem>
             <listitem>
                 <para>
                     <emphasis role="bold">2: Truncation</emphasis>
                 </para>
-                <para>The value at the first step is truncated </para>
+                <para>Truncating the number of quantization steps (output signal is the nearest step towards 0)</para>
             </listitem>
             <listitem>
                 <para>
                     <emphasis role="bold">3: Floor</emphasis>
                 </para>
-                <para>The floor value of the first step is used</para>
+               <para>Rounding down the number of quantization steps (output signal is the nearest step towards <latex>-\infty</latex>)</para>
             </listitem>
             <listitem>
                 <para>
                     <emphasis role="bold">4: Ceil</emphasis>
                 </para>
-                <para>The floor value of the first step is used</para>
+               <para>Rounding up the number of quantization steps (output signal is the nearest step towards <latex>+\infty</latex>)</para>
             </listitem>
         </itemizedlist>
     </refsection>
                 <para>
                     <emphasis role="bold">Quantization Type</emphasis>
                 </para>
-                <para> scalar with possible values 1,2,3 or 4 Properties : Type 'vec' of size 1. </para>
+                <para> scalar with possible values 1,2,3 or 4: the method of quantization used (respectively Truncation, Floor or Ceil)</para>
+               <para>Properties : Type 'vec' of size 1.</para>
             </listitem>
         </itemizedlist>
     </refsection>
     </refsection>
     <refsection id="Example_QUANT_f">
         <title>Example of a sine quantized every 0.2 step with the Ceil method (using the ceil value between two steps):</title>
-        <para>
-            <link type="scilab" linkend="scilab.xcos/xcos/examples/signalprocessing_pal/QUANT_f_Example.zcos">
-                <inlinemediaobject>
-                    <imageobject>
-                        <imagedata align="center" fileref="../../../../examples/signalprocessing_pal/QUANT_f_Example.zcos" valign="middle"/>
-                    </imageobject>
-                </inlinemediaobject>
-            </link>
+       <para>
+               <link type="scilab" linkend="scilab.xcos/xcos/examples/signalprocessing_pal/QUANT_f_Example.zcos">
+                       <inlinemediaobject>
+                               <imageobject>
+                                       <imagedata align="center" fileref="../../../../examples/signalprocessing_pal/QUANT_f_Example.zcos" valign="middle"/>
+                               </imageobject>
+                       </inlinemediaobject>
+               </link>
+       </para>
+       <para>
+               <scilab:image><![CDATA[
+                       importXcosDiagram(SCI + "/modules/xcos/examples/signalprocessing_pal/QUANT_f_Example.zcos");
+                       xcos_simulate(scs_m, 4);
+                       title("Quantization of a sine","fontsize",3)
+                       ]]></scilab:image>
+       </para>
+       </refsection><refsection id="Example_QUANT_f_Quantization_mode">
+       <title>Comparison of the different quantization modes:</title>
+       <para>
+               <link type="scilab" linkend="scilab.xcos/xcos/examples/signalprocessing_pal/QUANT_f_Example_Quantization_Mode.zcos">
+                       <inlinemediaobject>
+                               <imageobject>
+                                       <imagedata align="center" fileref="../../../../examples/signalprocessing_pal/QUANT_f_Example_Quantization_Mode.zcos" valign="middle"/>
+                               </imageobject>
+                       </inlinemediaobject>
+               </link>
         </para>
+       <para>
+               <scilab:image><![CDATA[
+                       importXcosDiagram(SCI + "/modules/xcos/examples/signalprocessing_pal/QUANT_f_Example_Quantization_Mode.zcos");
+                       xcos_simulate(scs_m, 4);
+                       title("Rounding strategy for the quantization type","fontsize",3)
+                       ]]></scilab:image>
+       </para>
     </refsection>
 </refentry>