Loïc Grenié on Wed, 17 Jan 2024 07:55:08 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Bizarre semantic of Mat


On Wed Jan 17th 2024 at 03:37, Ilya Zakharevich wrote:
Today I (finally) looked through the documentation of Mat() — and it
seems to be very convenient for interactive usage!  On the other hand,
such “cute” semantics have a tendency to become a limiting factor when
one wants to write down general-purpose algorithms…

Is there a simple way to convert a vector-column into a 1 column
matrix (without using matrix())?  Mat() is almost there — except for
bizarre special-cases — which are impossible to switch off!

     I confess I use the bizarre special-cases all the time...

     Anyway, if you have a column C and want a 1-column matrix,
  with C as only colon you can make Mat(vector(1,n,C)) (yes, I know,
  this is anti-intuitive, long, non-convenient, not explicitly documented,
  needed only because of bizarre semantics and uber-dirty).

    Same for row R: Mat(vectorv(1,n,R)) (same remarks).

         Loïc