(size)
| 96 | } |
| 97 | |
| 98 | const Identity = (size) => { |
| 99 | const isBigInt = typeof size === 'bigint' |
| 100 | const ZERO = isBigInt ? 0n : 0 |
| 101 | const ONE = isBigInt ? 1n : 1 |
| 102 | size = Number(size) |
| 103 | const I = Array(size) |
| 104 | .fill(null) |
| 105 | .map(() => Array(size).fill()) |
| 106 | return I.map((row, rowIdx) => |
| 107 | row.map((_col, colIdx) => { |
| 108 | return rowIdx === colIdx ? ONE : ZERO |
| 109 | }) |
| 110 | ) |
| 111 | } |
| 112 | |
| 113 | // A of size (l x m) and B of size (m x n) |
| 114 | // product C will be of size (l x n). |