reshape function

Matrix reshape(
  1. Matrix input,
  2. List<List<double>> fixedList
)

Implementation

Matrix reshape(Matrix input, List<List<double>> fixedList) {
  if (input.isEmpty) {
    return Matrix.fromList(fixedList);
  }

  List<double> flat = input
      .toList()
      .reduce((value, element) => value.toList() + element.toList())
      .toList();
  return Matrix.fromFlattenedList(
      flat, fixedList.length, fixedList.first.length);
}