public static double[,] AsSquareArray(MultiDimArrayDouble m) { var o = new double[m.Length0, m.Length1]; for (var i = 0; i < m.Length0; i++) { for (var j = 0; j < m.Length1; j++) { o[i, j] = m.BackingArray[i * m.Length0 + j]; } } return(o); }
public static double[][] AsJaggedArray(MultiDimArrayDouble m) { var o = new double[m.Length0][]; for (var i = 0; i < m.Length0; i++) { o[i] = new double[m.JaggedLengths[i]]; var lengthsSoFar = i == 0 ? 0 : m.JaggedLengths.Take(i).Sum(); for (var j = 0; j < m.JaggedLengths[i]; j++) { o[i][j] = m.BackingArray[lengthsSoFar + j]; } } return(o); }