Matrix.fromList constructor
Creates a matrix from a two dimensional list, every nested list is a source for a matrix row.
A simple usage example:
import 'package:ml_linalg/matrix.dart';
void main() {
final matrix = Matrix.fromList([
[1, 2, 3, 4, 5],
[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.fromList(
List<List<double>> source, {
DType dtype = DType.float32,
}) {
switch (dtype) {
case DType.float32:
return Float32Matrix.fromList(source);
case DType.float64:
return Float64Matrix.fromList(source);
default:
throw UnimplementedMatrixException(dtype);
}
}