Matrix.row constructor

Matrix.row(
  1. List<double> source, {
  2. DType dtype = DType.float32,
})

Creates a matrix, consisting of just one row (aka Row matrix)

import 'package:ml_linalg/matrix.dart';

void main() {
  final matrix = Matrix.row([1, 2, 3, 4, 5]);

  print(matrix);
}

The output:

Matrix 1 x 5:
(1.0, 2.0, 3.0, 4.0, 5.0)

Implementation

factory Matrix.row(
  List<double> source, {
  DType dtype = DType.float32,
}) {
  switch (dtype) {
    case DType.float32:
      return Float32Matrix.fromRows([Vector.fromList(source, dtype: dtype)]);

    case DType.float64:
      return Float64Matrix.fromRows([Vector.fromList(source, dtype: dtype)]);

    default:
      throw UnimplementedMatrixException(dtype);
  }
}