
Hi there I have to question for creating an app (where speed is critical)
What the faster way to do this :
1_ Operation result gives me a n lenght vector , I need to replace this vector with a n+1 lenght copy where vector[n] = 1.0;
2_ Fastest way to create a n*m matrix filled with random numbers (distribution ?)
thank you very much



That depends very much on what "speed is critical" means in practice. In any case you'd need to benchmark your specific scenario, but some pointers:
 Assuming a dense double vector, the fastest way will likely be along the lines of:
var raw = (double[])vector;
var raw2 = new double[raw.Length + 1];
Buffer.BlockCopy(raw, 0, raw2, 0, raw.Length * Constants.SizeOfDouble); raw2[raw2.Length1] = 1d;
var vector2 = (DenseVector)raw2;
 Slow: DoRandom() method. Faster:
const rows = 100, cols = 200;
var dist = new Normal();
var matrix = new DenseMatrix(rows, cols, dist.Samples().Take(rows * cols).ToArray());
Thanks,
Christoph

