Array.nonSquareIdentity constructor

Array.nonSquareIdentity({
  1. required Tuple2<int, int> shape,
})

Implementation

factory Array.nonSquareIdentity({required Tuple2<int, int> shape}) {
  var m = shape.item1;
  var n = shape.item2;

  var values = [
    for (var i in range(end: m))
      [
        for (var j in range(end: n))
          if (i == j) 1.0 else 0.0
      ]
  ];
  return Array(values: values);
}