Matrix.fromRows constructor
Creates a matrix with predefined row vectors
A simple usage example:
import 'package:ml_linalg/matrix.dart';
import 'package:ml_linalg/vector.dart';
void main() {
final matrix = Matrix.fromRows([
Vector.fromList([1, 2, 3, 4, 5]),
Vector.fromList([6, 7, 8, 9, 0]),
]);
print(matrix);
}
The output:
Matrix 2 x 5:
(1.0, 2.0, 3.0, 4.0, 5.0)
(6.0, 7.0, 8.0, 9.0, 0.0)
Implementation
factory Matrix.fromRows(List<Vector> source, {DType dtype = DType.float32}) {
switch (dtype) {
case DType.float32:
return Float32Matrix.fromRows(source);
case DType.float64:
return Float64Matrix.fromRows(source);
default:
throw UnimplementedMatrixException(dtype);
}
}