Identity matrix: Difference between revisions

Content added Content deleted
m (Updated description and link for Fōrmulæ solution)
(add BQN)
Line 635: Line 635:
blsq ) 6 ^^^^10\/**XXcy\/co.+sp
blsq ) 6 ^^^^10\/**XXcy\/co.+sp
</lang>
</lang>

=={{header|BQN}}==
<lang>⍝ Using table
Eye ← =⌜˜∘↕
•Show Eye 3

⍝ Using reshape
Eye1 ← {𝕩‿𝕩⥊1∾𝕩⥊0}
Eye1 5</lang>
<lang>┌─
╵ 1 0 0
0 1 0
0 0 1
┌─
╵ 1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
</lang>

<code>Eye</code> generates an identity matrix using a table of equality for [0,n).

<code>Eye1</code> reshapes a boolean vector to generate the matrix.

[https://mlochbaum.github.io/BQN/try.html#code=4o2dIFVzaW5nIHRhYmxlCkV5ZSDihpAgPeKMnMuc4oiY4oaVCuKAolNob3cgRXllIDMKCuKNnSBVc2luZyByZXNoYXBlCkV5ZTEg4oaQIHvwnZWp4oC/8J2VqeKlijHiiL7wnZWp4qWKMH0KRXllMSA1 Try it here!]


=={{header|C}}==
=={{header|C}}==