Matrix.fromFlattenedList constructor
Matrix.fromFlattenedList(})
Creates a matrix from flattened list of length equal to
rowCount
* columnCount
A simple usage example:
import 'package:ml_linalg/matrix.dart';
void main() {
final source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
final matrix = Matrix.fromFlattenedList(source, 2, 5);
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.fromFlattenedList(
List<double> source,
int rowCount,
int columnCount, {
DType dtype = DType.float32,
}) {
switch (dtype) {
case DType.float32:
return Float32Matrix.fromFlattenedList(source, rowCount, columnCount);
case DType.float64:
return Float64Matrix.fromFlattenedList(source, rowCount, columnCount);
default:
throw UnimplementedMatrixException(dtype);
}
}