diagonalVector method Null safety

Float32Vector diagonalVector()

Gets diagonal vector.

Implementation

Float32Vector diagonalVector() {
  if (isSquare) {
    throw UnsupportedError('Not a square matrix');
  }
  final builder = toBuilder();
  final width = this.width;
  builder.tensorShape = TensorShape(1, width);
  for (var i = 0; i < width; i++) {
    builder.setXY(0, i, getXY(i, i));
  }
  builder.tensorShape = TensorShape(width);
  return builder.build() as Float32Vector;
}