toVector abstract method

Vector toVector()

Tries to convert the Matrix to a vector:

import 'package:ml_linalg/matrix.dart';

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

  print(vector);
}

The output:

(1.0, 2.0, 3.0, 4.0, 5.0)

It fails, if both columnCount and rowCount are greater than 1:

import 'package:ml_linalg/matrix.dart';

void main() {
  final matrix = Matrix.fromList([
    [1.0, 2.0, 3.0, 4.0],
    [5.0, 6.0, 7.0, 8.0],
  ]);

  final vector = matrix.toVector();
}

The output:

Exception: Cannot convert 2 x 4 matrix into a vector

Implementation

Vector toVector();