You basically need a cross join in Linq. You can write an extension method, this way it looks like it is a Math.Net method:
namespace MathNet.Numerics
{
public static class DenseVectorExtensions
{
public static DenseVector AddAlls(this DenseVector vdA, DenseVector vdB)
{
return DenseVector.OfEnumerable(
vdA.SelectMany(x => vdB, (y, z) => { return y + z; })
);
}
}
}
Usage :
var vdA = new DenseVector(new[] { 8.0, 7.0, 6.0 });
var vdB = new DenseVector(new[] { 0.0, 1.0, 2.0, 3.0 });
var vdX = vdA.AddAlls(vdB);
This is not particularly faster.