Array.identity constructor

Array.identity(
  1. int size
)

Implementation

factory Array.identity(int size) {
  var values = [
    for (var i in range(end: size))
      [
        for (var j in range(end: size))
          if (i == j) 1.0 else 0.0
      ]
  ];
  var shape = Tuple2(size, size);
  return Array(values: values, shape: shape);
}