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

Convert MetaNumerics matrices to normal arrays

Mar 11, 2013 at 12:32 PM
Dear all,

I need to convert a type square matrix of yours into a simple "Matrix(,) as double", I looked in the documentation (.chm) for a method or function returning the matrix.
So far I only discovered that I can convert rows or column, but not the whole matrix:
Dim PtPr As SquareMatrix
Dim test() As Double = PtPr.Row(0).ToArray

Is there something better than:
Dim BestFit As SquareMatrix
Dim Tmat(,) As Double
ReDim Tmat(BestFit.RowCount - 1, BestFit.ColumnCount - 1)
For i As Integer = 0 To UBound(Tmat, 1)
  For j As Integer = 0 To UBound(Tmat, 2)
    Tmat(i, j) = BestFit(i, j)

Mar 12, 2013 at 7:57 PM
At the moment the code in your post is the way to do it. You could implement it as an extension method ( to AnyMatrix<T> so that it looks like a method on that class. I have filed a bug ( to create an actual method on that class for this purpose for the next release.