choleskyDecomposition function

List<List<double>> choleskyDecomposition(
  1. List<List<double>> input
)

Implementation

List<List<double>> choleskyDecomposition(List<List<double>> input) {
  data.Matrix<double> cholesky =
      data.Matrix<double>.fromRows(DataType.float64, input).cholesky.L;

  List<List<double>> output = [];

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

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

    output.add(row);
  }

  return output;
}