List<List<double>> matrixToList(Matrix input) { List<List<double>> output = []; for (var row in input) { output.add(row.toList()); } return output; }