This project has moved. For the latest updates, please go here.

Numerics 3.0 matrix construction syntax

Jan 25, 2015 at 5:37 PM
Edited Jan 25, 2015 at 5:46 PM
Sorry if this is a dumb question...

I would like to upgrade from an older version to current Numerics library.
I have lots of code of the form:

        double[][] ActualGaps = new double[10][];
        // ... fill in ActualGaps
        Matrix mB = new Matrix(ActualGaps); //create B from 10 row, 1 column array
New version of Numerics requires something like

        Matrix<double> mB = new Matrix(ActualGaps); //create B from 10 row, 1 column array
But that's still not correct; right side generates error:

  Error 1   Using the generic type 'MathNet.Numerics.LinearAlgebra.Matrix<T>' requires 1 type arguments
What's the correct syntax?

Thanks!
Coordinator
Jan 28, 2015 at 6:18 PM
You'll find some examples how matrices can be created in the docs: Creating Matrices and Vectors. Assuming your jagged array is organized by rows (i.e. the outer index is the row index):
Matrix<double> mB = Matrix<double>.Build.DenseOfRowArrays(ActualGaps);
// or
Matrix<double> mB = DenseMatrix.OfRowArrays(ActualGaps)
Thanks,
Christoph
Jan 29, 2015 at 4:28 PM
Thanks Christoph, I eventually figured this out...
Got tripped up by a number of very incompatible changes for which I found no documentation,
but all working OK now.
Thanks again,
Best Regards, Dave

On 1/28/2015 2:18 PM, cdrnet wrote:

From: cdrnet

You'll find some examples how matrices can be created in the docs: Creating Matrices and Vectors. Assuming your jagged array is organized by rows (i.e. the outer index is the row index):
Matrix<double> mB = Matrix<double>.Build.DenseOfRowArrays(ActualGaps);
// or
Matrix<double> mB = DenseMatrix.OfRowArrays(ActualGaps)
Thanks,
Christoph


-- 
Dave Nadler, USA East Coast voice (978) 263-0097, [email removed], Skype 
 Dave.Nadler1