## determinant of a matrix

APL-related discussions - a stream of APL consciousness.
Not sure where to start a discussion ? Here's the place to be
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !

### determinant of a matrix

What is the best way of calculating the determinant of a (square) matrix in APL?

(Take BEST in any way you like!)

Ray Cannon
Ray Cannon

ray

Posts: 137
Joined: Wed Feb 24, 2010 12:24 am
Location: Blackwater, Camberley. UK

### Re: determinant of a matrix

JohnS|Dyalog

Posts: 179
Joined: Wed Sep 10, 2008 10:01 am

### Re: determinant of a matrix

I was curious about how the code in http://dfns.dyalog.com/c_det.htm does on the Hilbert matrix, so I ran a benchmark.

Code: Select all
`   H←{÷1+∘.+⍨⍳⍵}    ⍝ Hilbert matrix of order ⍵   H 51        0.5      0.333333 0.25     0.2     0.5      0.333333 0.25     0.2      0.1666670.333333 0.25     0.2      0.166667 0.1428570.25     0.2      0.166667 0.142857 0.125   0.2      0.166667 0.142857 0.125    0.111111`

Now the determinants.

Code: Select all
`   )copy dfns detsaved ...   ¯18 ⍕ ⍪ det∘H¨ ⍳10 1.000000000000000__E0    1.000000000000000000e0 1.000000000000000__E0    1.000000000000000000e0   8.333333333333331__E¯2   8.333333333333333333e_2 4.629629629629614__E¯4   4.629629629629629630e_4 1.653439153439349__E¯7   1.653439153439153439e_7  3.749295132519431__E¯12  3.749295132515087164e_12 5.367299886702431__E¯18  5.367299887358687733e_18 4.835802601799728__E¯25  4.835802623926116932e_25 2.737050086319325__E¯33  2.737050113791513017e_33 9.720261264884943__E¯43  9.720234311924999863e_43`

On the right hand side I have put the values calculated in J using extended precision (exact) arithmetic.
Roger|Dyalog

Posts: 133
Joined: Thu Jul 28, 2011 10:53 am