gnu-octave / symbolic

A Symbolic Package for Octave using SymPy
https://octave.sourceforge.io/symbolic/
GNU General Public License v3.0
151 stars 36 forks source link

@sym/repmat: Not outputing empty matrices the same as repmat #1218

Closed alexvong243f closed 2 years ago

alexvong243f commented 2 years ago

Currently,

repmat(sym([1 2; 3 4]), 3, 0) outputs ans = (sym) [] (empty 3×0 matrix)

But

repmat([1 2; 3 4], 3, 0) outputs ans = [](6x0)

Which one is the correct behaviour? I don't think SMT documentation mentions this...

alexvong243f commented 2 years ago

While help repmat doesn't give us any information about this, help repelem seems to suggest the current hehaviour of repmat (but not @sym/repmat) is the correct one.

     'repelem' preserves the class of X, and works with strings, cell
     arrays, NA, and NAN inputs.  If any R_J is 0 the output will be an
     empty array.

          repelem ("Octave", 2, 3)
            =>    OOOccctttaaavvveee
                  OOOccctttaaavvveee

          repelem ([1 2 3; 1 2 3], 2, 0)
            =>    [](4x0)

     See also: cat, kron, repmat.
alexvong243f commented 2 years ago

Fixed in 65da8ab60c3a7b46a285697e20a1425ced570e6b