| Daisy code for OFF and PIV | Vertical-bar is the comment character. Carat is 'quote'. | Infix shriek is 'cons'. Infix colon is application. Backslash is 'lambda'. | A decorated matrix has the template, [[max ibit jbit] ! undecrtdmtx] | An undecorated matrix has the template, [NW NE SW SE] IDENT = \a.a SWAP= \[a b]. OFF = \[decorMtx elimrowcol pcolrow index]. if:< any?: <\[p].VOID?:p *>: decorMtx | Pivot row or col is 0. one?:index decorDIFFERENCE: > decorNORMALIZE:: < if: tail:decorMtx> spread4:elimrowcol :SWAP::spread4:SWAP:pcolrow < div: * > > >> spread4 = \[erow ecol]. let:[ [ [eleft eright] [etop ebot] ] isAtm?:erow erow > if: isAtm?:ecol ecol > > < >] PIVOT = \[decorMtx elimrowcol permutT]. if:< |returns | [decorMtx [elimrow elimcol] permutT [pivotrow pivotcol][ipos jpos]] | permutT is a permutation matrix---normalized | elimrow and elimcol are boolean vectors; | [] => that row is eliminated | pivotrow and pivotcol | are vectors of numbers, respectively | b/a and +c entries | except for pivot elt, which is 1/a or -1/a | ipos and jpos are inverse-bit rel indices of pivot elt Scalar?:decorMtx let:[ reciprocal scalarRECIPROCAL:decorMtx < reciprocal [[] []] 1 [1 1]> ] | Pivotrow entry is -1/a for pivot column construction | Pivotcol entry is +1/a for pivot row construction | No i,j coordinates here | because logarithms are zero; base case. let:[ [permutT [[max ibit jbit] ! mtx] [pII pIII pIV stet incr] ] permutT> decorMtx <\[i ii iii iv]. |pII permute NE quad to NW \[i ii iii iv]. |pIII permute SW quad to NW \[i ii iii iv]. |pIV permute SE quad to NW \n.add: |stet index builder \n.inc:add: |incr index builder > > let:[ [perMTX perPT perROW perCOL tweaki tweakj] | These are all permutations for arguments &/or results if:< | Make all cases uniformly manipulate upper-left quad all?: zero?:ibit zero?:jbit > let:[[ [epivot [] [] [eright ebot]] [permutHEAD!permutTAIL] ] < perMTX:spread4:elimrowcol perPT:permutT > rec:[ [ [i [eleft etop] permutPIVOT [pleft ptop] [ipos jpos]] [ii pright] [iii pbot] iv] :< perMTX:mtx > > <[] ipos jpos * > > let:[ [ elimrowcol pivotrowcol] < < if: [] perCOL:> if: [] perROW:> > perROW: > > > elimrowcol Normalize:perPT: pivotrowcol > ]]]] ]>