Apl2ToDoVectorizingAlgorithms

This is a sub-page of PhraseBook/ToDo/Apl2Idioms

M←⍉⊃VV ⍝ Column table. Vectors to columns of matrix.

M←⊃VV ⍝ Row table. Vectors to rows of a matrix.

VV←,⌿M ⍝ Matrix to vector of column vectors.

VV←⊂[1]M ⍝ Matrix to vector of row vectors.

VV←⊂[2]M ⍝ Matrix to vector of row vectors.

MV←⍉⊃⊂[1]¨VM ⍝ Vector of matrices to matrix of vectors.

MV←⍉⊃⊂[2]¨VM ⍝ Vector of matrices to matrix of vectors.

VV←↑,/⊂[1]¨VM ⍝ Vector of matrices to vector of vectors.

VV←↑,/⊂[2]¨VM ⍝ Vector of matrices to vector of vectors.

VM←⊃¨⊂[1]MV ⍝ Matrix of vectors to vector of matrices.

VM←⊃¨⊂[2]MV ⍝ Matrix of vectors to vector of matrices.

AV←↑,¨/VA ⍝ Joining corresponding items in vectrices.

M←↑,/MW MX MY ⍝ Joining conforming matrices - horizontally.

M←⊃↑,/⊂[1]¨MW MX MY ⍝ Joining matrices - vertically.

M←⊃↑,/⊂[2]¨MW MX MY ⍝ Joining matrices - vertically.

A←⊃,/AA ⍝ Joining array of arrays - horizontally.

M←⊃,[0]/AA ⍝ Joining array of arrays - vertically.

A←⊃,[1]/AA ⍝ Joining array of arrays - vertically.

A←,⊃AA ⍝ Enlist - top down. Remove highest nesting.

V←M[;0] ⍝ Vectorize - keep only 1st column of M.

V←M[;1] ⍝ Vectorize - keep only 1st column of M.

V←⊂[1↓⍳⍴⍴A]1/A ⍝ Vectorize - for any rank.

M←,[¯1↓⍳⍴⍴A]1/A ⍝ Matricize - for any rank.

M←((×/¯1↓⍴A),¯1↑1,⍴A)⍴A ⍝ Matricize - for any rank.

M←(¯2↑1 1,⍴A)⍴A ⍝ Matricize - rank 0, 1, or 2.

VV←(+/∨\⌽M≠' ')↑¨⊂[1]M ⍝ Reversing disclose.

VV←(+/∨\⌽M≠' ')↑¨⊂[2]M ⍝ Reversing disclose.

V←(⊂[1]M)~¨' ' ⍝ Reversing disclose. Eliminating blanks.

V←(⊂[2]M)~¨' ' ⍝ Reversing disclose. Eliminating blanks.

VA←⊃[1↓⍳⍴⍴A]¨(+\B)⊂⊂[1↓⍳⍴⍴A]A ⍝ Split A into a vector of arrays given B.

VV←(+\B)⊂V ⍝ Split V into subvectors given boolean B.

VV←(L/⍳⍴L)⊂V ⍝ Split V into subvectors indicated by L.

N←+/¨(+\B)⊂V ⍝ Sum of subvectors of V given boolean B.

N←+/¨(L/⍳⍴L)⊂V ⍝ Sum of subvectors of V indicated by L.

V←IS⊃(+\B)⊂V ⍝ ISth subvector of V given boolean B.

V←IS⊃(L/⍳⍴L)⊂V ⍝ ISth subvector of V given length L.

M←↑,/V,⊂M ⍝ Prefix vector to each row of matrix.

M←⊃,/M,⊂V ⍝ Postfix vector to each row of matrix.

A←⊃,/AX,⊂AY ⍝ Combine 2 arrays along their last dimension.

VV←⊃,/((⍴¨VV)⍴¨⊂1+LS↑1)⊂¨VV ⍝ Reblock. Cut VV into many ≤LS length vecs.

VV←⊂[2]B/⊃VV ⍝ Reduce each item of VV by B. (⍴B)^.=ε⍴¨VV


CategoryPhrasebookToDo

Apl2ToDoVectorizingAlgorithms (last edited 2011-04-25 14:01:59 by KaiJaeger)