trusted
183
edits
Miraheze>Marshall |
(→Notable uses: Point "identity matrix" to Wikipedia) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 28: | Line 28: | ||
</source> | </source> | ||
Reshape can also decrease the rank or [[bound]] of an array. One notable example is the use of an empty left argument <source lang=apl inline> | Reshape can also decrease the rank or [[bound]] of an array. One notable example is the use of an empty left argument [[Zilde]] (<source lang=apl inline>⍬</source>) to produce a [[scalar]]. The scalar is the first 0-[[cell]] of the right argument. In [[Nested array model|nested]] languages <source lang=apl inline>⍬⍴</source> is like [[First]] except that it does not remove a layer of nesting. | ||
<source lang=apl> | <source lang=apl> | ||
9 ⍴ ∘.+⍨ 1 2 1 | 9 ⍴ ∘.+⍨ 1 2 1 | ||
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]] |