I have a function that manipulates a Vector<float>
resulting a new Vector<float>
with different length, an example would be appending a number in front of the vector
let addElementInfront (x:Vector<float>) =
x.ToArray()
|> Array.append [|x.[0]|]
|> vector
Now I want to apply this to all the rows of a (2x2) matrix and I would expect a (2x3) matrix, I tried to use the Matrix.mapRows
of MathNet.Numerics.LinearAlgebra
but it gives me error that the size needs to be the same.
Just wonder if MathNet has any other function to map rows that results a different size matrix.
Thanks.
It seems you are trying to duplicate the first column of the matrix. For example:
If this is true, then the code could be:
UPDATE
Because the assumption above is not true.
So you can get the seq of the matrix rows, then transform it as usual with
Seq.map
, and finally make the result matrix: