Matrix<T>.vandermonde constructor

Matrix<T>.vandermonde(
  1. DataType<T> dataType,
  2. Vector<T> data,
  3. int columnCount, {
  4. MatrixFormat? format,
})

Returns a Vandermonde matrix, a matrix with the terms of a geometric progression in each row.

If format is specified the resulting matrix is mutable, otherwise this is a read-only view.

Implementation

factory Matrix.vandermonde(
    DataType<T> dataType, Vector<T> data, int columnCount,
    {MatrixFormat? format}) {
  final pow = dataType.field.pow;
  final exponents =
      Vector<T>.generate(dataType, columnCount, (i) => dataType.cast(i));
  return Matrix.generate(
      dataType, data.count, columnCount, (r, c) => pow(data[r], exponents[c]),
      format: format);
}