<html>
  <head>
    <meta http-equiv="content-type" content="text/html;
      charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <font face="Arial">Hi,<br>
      <br>
      A SEP 95 was recently submitted in CodeReview:<br>
      <a class="moz-txt-link-freetext"
href="https://codereview.scilab.org/cat/11455%2C2%2CSEP/SEP_095_ismatrix_isrow_iscolumn_issquare.odt">https://codereview.scilab.org/cat/11455%2C2%2CSEP/SEP_095_ismatrix_isrow_iscolumn_issquare.odt</a><br>
      <br>
      Despite no input is expected since the SEP has not been posted
      here (as not<br>
      foreseen by the SEP#0), here are a few comments about the
      proposal, for issquare(). <br>
      Other comments about other proposed functions will be posted in a
      separated thread.<br>
      <br>
      The full rationale says: <br>
    </font>
    <meta http-equiv="CONTENT-TYPE" content="text/html;
      charset=ISO-8859-1">
    <font color="#009900"><i>These functions are some elementary
        functions that exist in Matlab to check if a matrix or a </i><i><br>
      </i><i>vector is a matrix, a row, a column or a square matrix </i><br>
    </font><br>
    I have already written about the weight of any Matlab-mania. It
    looks here the main <br>
    and even single input argument for Scilab Enterprises. Then, i am
    wondering about what <br>
    should be the output, and if there is some tacit agreement between
    both companies. <br>
    <br>
    By the way, AFAIK, issquare() is not a native Matlab function. It is
    only proposed by a matlaber<br>
    in FileExchange.  IMO, the gain of introducing issquare() is very
    small.<br>
    <br>
    The proposed implementation is also very restricted:<br>
    <a class="moz-txt-link-freetext"
href="https://codereview.scilab.org/#/c/11455/2/scilab/modules/elementary_functions/macros/issquare.sci">https://codereview.scilab.org/#/c/11455/2/scilab/modules/elementary_functions/macros/issquare.sci</a>
    :<br>
    <pre style="font-family:Monospaced;font-style:normal;font-size:14.0;"><span style="color:rgb(176,24,19);">function</span> <span style="color:rgb(131,67,16);font-weight:bold;">r</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(0,0,0);text-decoration:underline;">issquare</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(131,67,16);font-weight:bold;">v</span><span style="color:rgb(74,85,219);">)
   // (checking input parameters. Then:)
</span>   <span style="color:rgb(160,32,240);">if</span> <span style="color:rgb(50,185,185);">size</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(50,185,185);">size</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(131,67,16);font-weight:bold;">v</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(188,143,143);">'</span><span style="color:rgb(188,143,143);">*</span><span style="color:rgb(188,143,143);">'</span><span style="color:rgb(74,85,219);">)</span> <span style="color:rgb(92,92,92);">==</span> <span style="color:rgb(188,143,143);">1</span> <span style="color:rgb(92,92,92);">|</span> <span style="color:rgb(50,185,185);">size</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(131,67,16);font-weight:bold;">v</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(188,143,143);">1</span><span style="color:rgb(74,85,219);">)</sp
 an> <sp
 an="" style="color:rgb(92,92,92);">== <span style="color:rgb(188,143,143);">1</span> <span style="color:rgb(160,32,240);">then</span>
        <span style="color:rgb(131,67,16);font-weight:bold;">r</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(218,112,214);">%f</span><span style="color:rgb(0,0,0);">;</span>
    <span style="color:rgb(160,32,240);">elseif</span> <span style="color:rgb(50,185,185);">size</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(131,67,16);font-weight:bold;">v</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(188,143,143);">1</span><span style="color:rgb(74,85,219);">)</span> <span style="color:rgb(92,92,92);">==</span> <span style="color:rgb(50,185,185);">size</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(131,67,16);font-weight:bold;">v</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(188,143,143);">2</span><span style="color:rgb(74,85,219);">)</span>
        <span style="color:rgb(131,67,16);font-weight:bold;">r</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(218,112,214);">%t</span><span style="color:rgb(0,0,0);">;</span>
    <span style="color:rgb(160,32,240);">else</span> 
        <span style="color:rgb(131,67,16);font-weight:bold;">r</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(218,112,214);">%f</span><span style="color:rgb(0,0,0);">;</span>
    <span style="color:rgb(160,32,240);">end</span>
<span style="color:rgb(176,24,19);">endfunction</span></sp></pre>
    <br>
    <b>Suggested definition</b>: issquare(v) should return %T as soon as
    all non-null dimensions of v <br>
    (that are not singleton) are equal.<br>
    For example, this means, for any type of data in matrix or
    hypermatrix, with dense or sparse encoding:<br>
    <br>
    <tt>issquare([])            // => %F : this could be conventional</tt><tt><br>
    </tt><tt>issquare(%pi)           // => %T</tt><tt> : yes, a
      scalar is a square matrix</tt><br>
    <tt>issquare(emptystr(2,2)) // => %T</tt><tt> , as expected</tt><tt><br>
    </tt><tt><tt>issquare(rand(2,1,2))   // => %T</tt><tt> , oriented
        along (x,z) instead of (x,y), but truly square.</tt><tt><br>
      </tt>issquare(rand(2,2,2))   // => %T</tt><tt> : a
      straighforward extension to 3D. <br>
                 // There is no reason to implement specific iscube(),
      ishypercube().. functions<br>
    </tt><tt><tt><tt>issquare(rand(2,2,3))   // => %F</tt> : only
        cubes accepted<br>
        issquare(rand(2,2,2,2)) // => %T</tt><tt>...<br>
      </tt></tt><br>
    <tt>While the present implementation disagrees in the following
      cases:<br>
      -->issquare([])<br>
       ans  =<br>
        T  <br>
      <br>
      -->issquare(%pi)<br>
       ans  =<br>
        F  <br>
       <br>
      -->issquare(rand(2,1,2))<br>
       ans  =<br>
        F  <br>
       <br>
      -->issquare(rand(2,2,3))<br>
       ans  =<br>
        T  <br>
       <br>
      So, what do we do?<br>
      <br>
      Here is an alternate implementation, if one is really required:</tt><br>
    <pre style="font-family:Monospaced;font-style:normal;font-size:14.0;"><span style="color:rgb(176,24,19);">function</span> <span style="color:rgb(131,67,16);font-weight:bold;">r</span><span style="color:rgb(92,92,92);"> = </span><span style="color:rgb(0,0,0);text-decoration:underline;">issquare</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(131,67,16);font-weight:bold;">v</span><span style="color:rgb(74,85,219);">)</span>
    <span style="color:rgb(0,0,0);">s</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">size</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(174,92,176);text-decoration:underline;">squeeze</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(131,67,16);font-weight:bold;">v</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(74,85,219);">)</span>
    <span style="color:rgb(0,0,0);">s</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(0,0,0);">s</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">s</span><span style="color:rgb(92,92,92);">></span><span style="color:rgb(188,143,143);">0</span><span style="color:rgb(74,85,219);">)</span>   // to reject [ ]
    <span style="color:rgb(131,67,16);font-weight:bold;">r</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">length</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(174,92,176);text-decoration:underline;">unique</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">s</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(92,92,92);">==</span><span style="color:rgb(188,143,143);">1</span>
<span style="color:rgb(176,24,19);">endfunction
<big>
</big></span></pre>
    <small><span style="color:rgb(176,24,19);"><big><font
            color="#000000">To be tested on sparse samples.<br>
            Since there are here likely hundreds of subscribers, other
            inputs would be welcome.<br>
            Designing Scilab should be the matter of all present and
            forthcoming users. </font></big></span><br>
      <br>
      <span style="color:rgb(176,24,19);"><big><font color="#000000">Regards</font></big></span><br>
      <span style="color:rgb(176,24,19);"><big><font color="#000000">Samuel


            Gougeon</font></big></span></small><br>
    <span style="color:rgb(176,24,19);"></span><span
      style="color:rgb(176,24,19);"><br>
    </span>
    <title></title>
    <meta name="GENERATOR" content="OpenOffice.org 3.4.1 (Win32)">
    <style type="text/css">
        <!--
                @page { margin: 2cm }
                P { margin-bottom: 0.21cm }
        -->
        </style>
  </body>
</html>