matrixSolve function

List<List<double>> matrixSolve(
  1. List<List<double>> a,
  2. List<List<double>> b
)

Implementation

List<List<double>> matrixSolve(List<List<double>> a, List<List<double>> b) {
  data.Matrix<double> solved = data.Matrix<double>.fromRows(DataType.float64, a)
      .solve(data.Matrix<double>.fromRows(DataType.float64, b));
  List<List<double>> output = [];

  for (int i = 0; i < solved.columnCount; i++) {
    List<double> row = [];

    for (int j = 0; j < solved.rowCount; j++) {
      row.add(solved.get(j, i));
    }

    output.add(row);
  }

  return output;
}