<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <font face="Arial">Hello,<br>
      <br>
      This SEP has been posted under the review
      <a class="moz-txt-link-freetext" href="https://codereview.scilab.org/#/c/11455/">https://codereview.scilab.org/#/c/11455/</a> :<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>
      The case of issquare() is discussed in the separated thread<br>
      <a class="moz-txt-link-freetext" href="http://mailinglists.scilab.org/SEP-95-issquare-tt4026683.html">http://mailinglists.scilab.org/SEP-95-issquare-tt4026683.html</a><br>
      <br>
    </font><font face="Arial">The full rationale of this SEP says: <br>
    </font> <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>
      <br>
      <font color="#000000">No more comments about this a-priori Matlab
        worship.<br>
        About these 4 functions: difficult to me thinking that their
        implementation is a priority,<br>
        or even really needed. Let's consider that they could be useful,
        and start with the most <br>
        provocative one:<br>
        <br>
        <b>IsAScalar()</b>:<br>
         * is replacing </font></font><font color="#009900"><font
        color="#000000"><tt>size(A,"*")==1</tt></font></font><font
      color="#009900"><font color="#000000"> with</font></font><font
      color="#009900"><font color="#000000"><tt> IsAScalar(A)</tt></font></font><font
      color="#009900"><font color="#000000"> worthwhile??<br>
            About it: where are the capitals? I have already
        forgotten... Happily,<br>
            there are 5 help maintained pages in en, fr, ru, pt and ja
        to get them.<br>
            Ouf.<br>
            Pushing Scilab on this side, it should finally fall...<br>
            By the way, won't matlabers -- that are expected to love it
        -- shout<br>
            "Is it isscalar(), or something else ?"   <br>
            It would rather deserve a class action against it, wouldn't
        it? At least.<br>
            By the way, the posted help page says that IsAScalar() could
        be applied<br>
            only to decimals. I agree, it will never be too weak :-) <br>
            How is it possible to still weaken it?<br>
            Sorry for this bad mood...<br>
        <br>
        For the next 3 functions that are proposed:<b> isrow(),
          iscolumn() and ismatrix()</b>, the <br>
        following features are discussed:<br>
         * case of []  : <br>
            The answer should be conventional: either the answer is %T
        for the 3 functions, <br>
            or it is %F for the 3. <br>
            Matlab answers look unconsistent. They are:<br>
           </font></font><font color="#009900"><font color="#000000"><tt>
          isrow([])  => 0</tt></font></font><font color="#009900"><font
        color="#000000">    <br>
             </font></font><font color="#009900"><font color="#000000"><tt>iscolumn([])
          => 0</tt></font></font><font color="#009900"><font
        color="#000000">   but   </font></font><font color="#009900"><font
        color="#000000"><tt> <br>
             ismatrix([]) => 1</tt></font></font><font
      color="#009900"><font color="#000000"><br>
            Could anyone explain how and why, while any other non-empty 
        <br>
            column or row is detected as a matrix, [] is also claimed to
        be a matrix()<br>
            but neither a row nor a column..<br>
        <br>
            The present Scilab implementation gives:<br>
      </font></font><font color="#009900"><font color="#000000"><font
          color="#009900"><font color="#000000">    isrow([])  => %F
               iscolumn([]) => %F   but    ismatrix([]) => %T<br>
                So, it is Matlab-compatible. It is likely its overal
            business.<br>
          </font></font>   <br>
         * case of a scalar (says %pi):<br>
            Matlab returns:<br>
      </font></font><font color="#009900"><font color="#000000"><tt>   
          isrow(pi)    => </tt><tt>1</tt><tt><br>
        </tt><tt>    iscolumn(pi) => </tt><tt>1</tt><tt><br>
        </tt><tt>    ismatrix(pi) </tt><tt>=> 1</tt><tt><br>
        </tt></font></font><font color="#009900"><font color="#000000">   
        I definitely agree with Matlab, despite the Matlab-mania of
        Scilab is weakening...:<br>
      </font></font><font color="#009900"><font color="#000000"><font
          color="#009900"><font color="#000000"><tt>    isrow(%pi)   
              => %F<br>
            </tt><tt>    iscolumn(%pi) => %F<br>
            </tt><tt>    ismatrix(%pi) </tt><tt>=> %F</tt><tt><br>
            </tt></font></font>   <br>
         * case of an hypermatrix with singleton dimension(s): <br>
            - Matlab returns always 0 (false) for any input hypermatrix,
        for the 3 functions,<br>
               even when it has singleton dimension, say: </font></font><font
      color="#009900"><font color="#000000"><tt>ismatrix(rand(2,1,2))
          => 0</tt></font></font><font color="#009900"><font
        color="#000000"><br>
            - This behaviour is debattable. Scilab could be more
        comprehensive at no <br>
              expenses:<br>
        <br>
         * Here are some suggested implementations (without overhead):<br>
      </font></font><font color="#009900"><font color="#000000"><font
          color="#009900"><tt>     function r = ismatrix(A)</tt><tt><br>
          </tt><tt>         s = size(squeeze(A)</tt><tt>)</tt><tt><br>
          </tt><tt>         s = length(s(s>0)</tt><tt>)</tt><tt><br>
          </tt><tt>         r = s>0 & s<3 </tt><tt><br>
          </tt></font><tt><font color="#009900">     endfunction<br>
          </font></tt></font></font>       giving:<font color="#009900"><font
        color="#000000"><tt><font color="#009900"><br>
            <font color="#993300">    ismatrix([])          // %F</font></font></tt></font></font><font
      color="#993300"><br>
      <tt><tt>    ismatrix(%pi)         // %T<br>
        </tt></tt><tt><tt><tt>    ismatrix([1,1])       // %T</tt></tt></tt><br>
      <tt>    ismatrix([1;1])       // %T</tt><br>
      <tt>    ismatrix(rand(2,3))   // %T</tt><br>
      <tt>    ismatrix(rand(2,3,2)) // %F<br>
      </tt></font><font color="#009900"><font color="#000000"><font
          color="#993300"><tt><tt>    ismatrix(rand(2,1,3)) // %T</tt></tt></font><br>
      </font></font><br>
    <font color="#009900"><font color="#000000"><font color="#009900"><font
            color="#000000"><font color="#009900"><tt>     function r =
                isrow(A)</tt><tt><br>
              </tt><tt>         s = size(A</tt><tt>)<br>
                         s2 = s(find(s(2:$)>=1))<br>
              </tt><tt> </tt><tt>         r = s(1)==1 &
                (length(s2)==1 | prod(s2)==1)</tt><tt><br>
              </tt></font><tt><font color="#009900">     endfunction<br>
              </font></tt></font></font></font></font><font
      color="#009900"><font color="#000000">       giving:<font
          color="#009900"><font color="#000000"><tt><font
                color="#009900"><br>
                <font color="#993300">    isrow([])          // %F</font></font></tt></font></font><font
          color="#993300"><br>
          <tt><tt>    isrow(%pi)         // %T<br>
            </tt></tt><tt><tt><tt>    isrow([1,1])       // %T</tt></tt></tt><br>
          <tt>    isrow([1;1])       // %F</tt><br>
          <tt>    isrow(rand(2,3))   // %F</tt><br>
          <tt>    isrow(rand(1,3,2)) // %F<br>
          </tt></font><font color="#009900"><font color="#000000"><font
              color="#993300"><tt><tt>    isrow(rand(1,1,3)) // %T</tt></tt></font></font></font></font></font><br>
    <font color="#009900"><font color="#000000"><font color="#009900"><font
            color="#000000"><font color="#009900"><font color="#000000"><font
                  color="#993300"><tt><tt>    isrow(rand(2,1,1)) // %F<br>
                      <br>
                    </tt></tt></font></font></font></font></font>
                and finally:<br>
      </font></font><br>
    <font color="#009900"><font color="#000000"><font color="#009900"><font
            color="#000000"><font color="#009900"><tt>     function r =
                iscolumn(A)</tt><tt><br>
              </tt><tt>         s = size(A</tt><tt>)</tt><tt><br>
              </tt><tt>         r = s(1)>=1 & length(find(s(2:$)>1))==0</tt><tt><br>
              </tt></font><tt><font color="#009900">     endfunction<br>
              </font></tt></font></font></font></font><font
      color="#009900"><font color="#000000">       giving:<font
          color="#009900"><font color="#000000"><tt><font
                color="#009900"><br>
                <font color="#993300">    iscolumn([])          // %F</font></font></tt></font></font><font
          color="#993300"><br>
          <tt><tt>    iscolumn(%pi)         // %T<br>
            </tt></tt><tt><tt><tt>    iscolumn([1,1])       // %F</tt></tt></tt><br>
          <tt>    iscolumn([1;1])       // %T</tt><br>
          <tt>    iscolumn(rand(2,3))   // %F</tt><br>
          <tt>    iscolumn(rand(1,1,3)) // %F<br>
          </tt></font><font color="#009900"><font color="#000000"><font
              color="#993300"><tt><tt>    iscolumn(rand(3,1,1)) // %T</tt></tt></font></font></font></font></font><br>
    <font color="#009900"><font color="#000000"><br>
        Comments of any forthcoming user would be very appreciable.<br>
        Hope to read them soon,<br>
        <br>
        Regards<br>
        Samuel Gougeon<br>
        <br>
      </font></font>
  </body>
</html>