I am building a matrix class ( I am aware one exists), I'm thinking about initialization. Currently one of the initializations is
double[,] data;
public Matrix(double[,] data)
{
if (data.GetLength(0) == 0 || data.GetLength(1) == 0)
{
throw new ArgumentException();
}
this.data = (double[,])(data.Clone());
}
which is nice because it can be initialized like
Matrix matrix= new Matrix(new double[,]{{1, 0 , 0 },
{1, 0.5, 0 }});
Is there a way to do this more compact, something like
Matrix matrix= new Matrix{{1,0}, {1,1}, {1,5}};
or even better
Matrix matrix = {{1,0}, {1,1}, {1,5}};
?