Hello,

This SEP has been posted under the review https://codereview.scilab.org/#/c/11455/ :
https://codereview.scilab.org/cat/11455%2C2%2CSEP/SEP_095_ismatrix_isrow_iscolumn_issquare.odt

The case of issquare() is discussed in the separated thread
http://mailinglists.scilab.org/SEP-95-issquare-tt4026683.html

The full rationale of this SEP says:
/These functions are some elementary functions that exist in Matlab to check if a matrix or a //
//vector is a matrix, a row, a column or a square matrix /

No more comments about this a-priori Matlab worship.
About these 4 functions: difficult to me thinking that their implementation is a priority, or even really needed. Let's consider that they could be useful, and start with the most
provocative one:

*IsAScalar()*:
 * is replacing size(A,"*")==1withIsAScalar(A)worthwhile??
    About it: where are the capitals? I have already forgotten... Happily,
    there are 5 help maintained pages in en, fr, ru, pt and ja to get them.
    Ouf.
    Pushing Scilab on this side, it should finally fall...
    By the way, won't matlabers -- that are expected to love it -- shout
    "Is it isscalar(), or something else ?"
It would rather deserve a class action against it, wouldn't it? At least.
    By the way, the posted help page says that IsAScalar() could be applied
    only to decimals. I agree, it will never be too weak :-)
    How is it possible to still weaken it?
    Sorry for this bad mood...

For the next 3 functions that are proposed:*isrow(), iscolumn() and ismatrix()*, the
following features are discussed:
 * case of []  :
The answer should be conventional: either the answer is %T for the 3 functions,
    or it is %F for the 3.
    Matlab answers look unconsistent. They are:
isrow([])  => 0
iscolumn([]) => 0  but
   ismatrix([]) => 1
    Could anyone explain how and why, while any other non-empty
column or row is detected as a matrix, [] is also claimed to be a matrix()
    but neither a row nor a column..

    The present Scilab implementation gives:
    isrow([])  => %F    iscolumn([]) => %F   but    ismatrix([]) => %T
    So, it is Matlab-compatible. It is likely its overal business.

 * case of a scalar (says %pi):
    Matlab returns:
isrow(pi)    => 1
    iscolumn(pi) => 1
    ismatrix(pi) => 1
I definitely agree with Matlab, despite the Matlab-mania of Scilab is weakening...:
    isrow(%pi) => %F
    iscolumn(%pi) => %F
    ismatrix(%pi) => %F

 * case of an hypermatrix with singleton dimension(s):
- Matlab returns always 0 (false) for any input hypermatrix, for the 3 functions, even when it has singleton dimension, say: ismatrix(rand(2,1,2)) => 0 - This behaviour is debattable. Scilab could be more comprehensive at no
      expenses:

 * Here are some suggested implementations (without overhead):
     function r = ismatrix(A)
         s = size(squeeze(A))
         s = length(s(s>0))
         r = s>0 & s<3
     endfunction
       giving:
    ismatrix([])          // %F
    ismatrix(%pi)         // %T
    ismatrix([1,1])       // %T
    ismatrix([1;1])       // %T
    ismatrix(rand(2,3))   // %T
    ismatrix(rand(2,3,2)) // %F
    ismatrix(rand(2,1,3)) // %T

     function r = isrow(A)
         s = size(A)
         s2 = s(find(s(2:$)>=1))
         r = s(1)==1 & (length(s2)==1 | prod(s2)==1)
     endfunction
       giving:
    isrow([])          // %F
    isrow(%pi)         // %T
    isrow([1,1])       // %T
    isrow([1;1])       // %F
    isrow(rand(2,3))   // %F
    isrow(rand(1,3,2)) // %F
    isrow(rand(1,1,3)) // %T
    isrow(rand(2,1,1)) // %F

        and finally:

     function r = iscolumn(A)
         s = size(A)
         r = s(1)>=1 & length(find(s(2:$)>1))==0
     endfunction
       giving:
    iscolumn([])          // %F
    iscolumn(%pi)         // %T
    iscolumn([1,1])       // %F
    iscolumn([1;1])       // %T
    iscolumn(rand(2,3))   // %F
    iscolumn(rand(1,1,3)) // %F
    iscolumn(rand(3,1,1)) // %T

Comments of any forthcoming user would be very appreciable.
Hope to read them soon,

Regards
Samuel Gougeon

_______________________________________________
dev mailing list
[email protected]
http://lists.scilab.org/mailman/listinfo/dev

Reply via email to