public static Matrix constructWithCopy(double[][] A) {
int m = A.Length;
int n = A[0].Length;
Matrix X = new Matrix(m, n);
double[][] C = X.getArray();
for (int i = 0; i < m; i++) {
if (A[i].Length != n)
{
throw new ArgumentOutOfRangeException(
"All rows must have the same length.");
}
for (int j = 0; j < n; j++) {
C[i][j] = A[i][j];
}
}
return X;
}