This project has moved and is read-only. For the latest updates, please go here.

Shouldn't Generic.Matrix<T>.Random be a static method?

Nov 7, 2012 at 12:06 PM

Hi,

Shouldn't the Random method be static? Since the params of the method ask again for row numbers and column number, what is the point of using it as member method? 

If it is a member method shouldn't it automatically replace all the elements of the object with some random number from the picked distribution?

Nov 17, 2012 at 11:01 AM
Edited Nov 17, 2012 at 11:02 AM

I also find this peculiar , Random Vector is also not static and generates a new random vector that bears no relationship to the instance that created it, other than the fact that both are of the same type .

https://github.com/mathnet/mathnet-numerics/issues/49

 

Nov 19, 2012 at 7:33 AM

Yes, Random was originally intended as a template method, just like CreateMatrix and CreateVector, i.e. to create an object of the same specific type in a generic way, supporting efficient algorithm implementations (kind of a structural clone without data). However, in the case of Random it doesn't really make sense anymore and is only used in one unit test, so we may want to drop that.

On the other hand, a static Random factory function would indeed be useful, I agree we should add that.

Thanks,
Christoph

Nov 25, 2012 at 12:26 AM

FYI, I've just committed to mainline: all DenseMatrix and DenseVector classes now have static CreateRandom functions (replacing the old random template methods).

Marked as answer by cdrnet on 10/3/2013 at 5:52 PM