filledWithScalar function

Matrix filledWithScalar(
  1. int rows,
  2. int? columns,
  3. num scalar
)

Implementation

Matrix filledWithScalar(int rows, int? columns, num scalar) {
  columns ??= rows;
  assert(rows > 0 && columns > 0);

  List<Vector> listOfRows = [];
  Vector scalarVector = Vector.filled(columns, scalar);

  for (int i = 0; i < rows; i++) {
    listOfRows.add(scalarVector);
  }

  return Matrix.fromRows(listOfRows);
}