MCPcopy Index your code
hub / github.com/TheAlgorithms/JavaScript / Identity

Function Identity

Maths/Fibonacci.js:98–111  ·  view source on GitHub ↗
(size)

Source from the content-addressed store, hash-verified

96}
97
98const 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).

Callers 1

matrixExpoFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected