Float32Matrix.fromRows constructor

Float32Matrix.fromRows(
  1. Iterable<List<double>> rows
)

Constructs a matrix from rows.

Example

import 'package:calc/calc.dart';

void main() {
  final matrix = Matrixf.fromRows([
    [1.0, 2.0],
    [3.0, 4.0],
    [5.0, 6.0],
  ]);
}

Implementation

factory Float32Matrix.fromRows(Iterable<List<double>> rows) {
  final builder = Float32TensorBuilder();
  builder.tensorShape = TensorShape(rows.first.length, rows.length);
  var y = 0;
  for (var row in rows) {
    for (var x = 0; x < row.length; x++) {
      builder.setXY(x, y, row[x]);
    }
    y++;
  }
  return builder.build() as Float32Matrix;
}