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

DenseMatrix data copying

Coordinator
Oct 16, 2009 at 9:37 PM

Hi All,

I have a very bare bones implementations for DenseMatrix ready but am wondering what you think about initializing the class:

DenseMatrix(double[] data) : should this guy just reference data (as we do in DenseVector)?

DenseMatrix(double[,] data) : should this guy copy the data or is there a smart way to cast this to a one dimensional array and reference that?

On one hand I like the referencing, on the other hand, having two constructors which look so similar but behave completely different is a bit confusing.

Cheers, Jurgen

Oct 17, 2009 at 5:50 AM

Hi Jurgen,

>DenseMatrix(double[] data) : should this guy just reference data (as we do in DenseVector)?

I prefer it to be a reference.  This will give us a performance boost with the Matlab parser and other library interop. 

>is there a smart way to cast this to a one dimensional array and reference that?

I thought there might be something in the runtime interop classes, but it doesn't look it. We might be able to do it with pointer manipulation, but then the code has to marked as unsafe. It looks like copying might be the only option.

>having two constructors which look so similar but behave completely different is a bit confusing.

Agreed, it might be a bit confusing - but as long as it is documented it should be OK.

Regards,

Marcus

 

 

Coordinator
Oct 18, 2009 at 3:10 PM

OK, first initial methods for DenseMatrix are checked in. Maybe someone can double check the memory layout of the dense matrix and sign off?

Cheers, Jurgen

Oct 19, 2009 at 7:55 AM

The memory layout looks fine.  I didn't see the constructor that takes an array though.

Regards,
Marcus 

Coordinator
Oct 19, 2009 at 8:47 AM

I'll add that constructor later today. Thanks for reviewing.

Jurgen