Apl2ToDoComputationalAlgorithms

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

N←NS+/N ⍝ Running sum of NS consecutive elements of N.

N←¯2-/0,N ⍝ Inverse of +\. Difference of adjacent pairs.

N←↑-//NS 1/¯2 N ⍝ NS differences of differences of adjacents.

N←-\⍳IS ⍝ Alternating series of length IS(1,-1,2,-2..).

I←+\1+⍳IS ⍝ First IS triangular numbers.

I←+\⍳IS ⍝ First IS triangular numbers.

I←+\+\1+⍳IS ⍝ First IS figurative numbers.

I←+\+\⍳IS ⍝ First IS figurative numbers.

NA←AX÷AY+AY=0 ⍝ Division. Avoid DOMAIN ERROR for N÷0.

NA←AX×÷AY ⍝ Division. Force DOMAIN ERROR for 0÷0.

N←100×NM÷[1]+⌿NM ⍝ Col-wise percentage per column.

N←100×NM÷[2]+⌿NM ⍝ Col-wise percentage per column.

N←100×NM÷[0]+/NM ⍝ Row-wise percentage per row.

N←100×NM÷[1]+/NM ⍝ Row-wise percentage per row.

NA←NA×|NA ⍝ Square without changing sign.

NM←NM+[1]N ⍝ Add vector N to each column of NM.

NM←NM+[2]N ⍝ Add vector N to each column of NM.

NM←NM×[0]N ⍝ Multiply each row of NM by vector N.

NM←NM×[1]N ⍝ Multiply each row of NM by vector N.

NS←÷+/÷N ⍝ Ohm's Law - resistance of parallelresistors.

NS←-/×⌿0 1⌽M ⍝ Evaluating a two row determinant.

NS←-/+/¨×⌿¨(1 ¯1×⊂0 1 2)⌽¨⊂M ⍝ Evaluating a three row determinant.

M←IS IS⍴1,IS⍴0 ⍝ Identity matrix: IS by IS.

M←↑⌹/0⍴⊂IS⍴0 ⍝ Identity matrix: IS by IS.

M←(⍳IS)∘.=⍳IS ⍝ Identity matrix: IS by IS.

M←(1+⍳IS)∘.×1+⍳IS ⍝ Multiplication table: IS by IS.

M←(⍳IS)∘.×⍳IS ⍝ Multiplication table: IS by IS.

M←(⍳IS)∘.>⍳IS ⍝ Lower triangular matrix: IS by IS.

M←X∘.×Y ⍝ Outer product.

M←MX+.×MY ⍝ Matrix product.

A←AX,.×AY ⍝ Mid product of AX and AY.

I←(2=+⌿0=I∘.|I)/I←1+⍳IS ⍝ Prime numbers from 1...IS.

I←(2=+⌿0=I∘.|I)/I←⍳IS ⍝ Prime numbers from 1...IS.

IS←⌈/(^/0=V∘.|I)/V←1+⍳⌊/I ⍝ Greatest common divisor of vector I.

IS←⌈/(^/0=V∘.|I)/V←⍳⌊/I ⍝ Greatest common divisor of vector I.

M←0=(1+⍳⌈/I)∘.|I ⍝ Table of divisibility.

M←0=(⍳⌈/I)∘.|I ⍝ Table of divisibility.

NS←+/εNA ⍝ Sum of all elements in NA.

I←(0=I|IS)/I←2+⍳⌊IS÷2 ⍝ All factors of IS.

I←(0=I|IS)/I←1+⍳⌊IS÷2 ⍝ All factors of IS.

FS←+/F[⍒|F] ⍝ Accurately sum a vector of floating numbers.

FA←NA⍟A ⍝ Find the exponent of NA such that NA*FA = A.


CategoryPhrasebookToDo

Apl2ToDoComputationalAlgorithms (last edited 2011-04-25 12:30:25 by KaiJaeger)