Reshape: Difference between revisions

Jump to navigation Jump to search
75 bytes added ,  06:53, 10 June 2020
→‎Notable uses: Point "identity matrix" to Wikipedia
(→‎Notable uses: Point "identity matrix" to Wikipedia)
(2 intermediate revisions by 2 users not shown)
Line 65: Line 65:
</source>
</source>
{{Works in|[[Dyalog APL]]}}
{{Works in|[[Dyalog APL]]}}
Here the right argument is converted to a ravel vector by ravelling and appending the [[prototype]], then [[indexing]] to produce a vector of the correct length. The indices used are the ravel indices of the result, but they are made to wrap around using [[Residue]].
Here the right argument is converted to a ravel vector by ravelling and appending the [[prototype]], then [[Bracket indexing|indexing]] to produce a vector of the correct length. The indices used are the ravel indices of the result, but they are made to wrap around using [[Residue]].


== J variant: Shape ==
== J variant: Shape ==
Line 73: Line 73:
== Notable uses ==
== Notable uses ==


Reshape can be used to produce an [[identity matrix]] by reshaping a vector which is one longer than the desired side length.
Reshape can be used to produce an [[wikipedia:identity matrix|identity matrix]] by reshaping a vector which is one longer than the desired side length.
<source lang=apl>
<source lang=apl>
       4 4 ⍴ 5↑1
       4 4 ⍴ 5↑1
Line 97: Line 97:
* [https://code.jsoftware.com/wiki/Vocabulary/dollar#dyadic J Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/dollar#dyadic J NuVoc] (as <source lang=apl inline>$</source> "Shape")  
* [https://code.jsoftware.com/wiki/Vocabulary/dollar#dyadic J Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/dollar#dyadic J NuVoc] (as <source lang=apl inline>$</source> "Shape")  


{{APL built-ins}}
{{APL built-ins}}[[Category:Primitive functions]]
trusted
183

edits

Navigation menu