determinant of a matrix
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 !
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 !
3 posts
• Page 1 of 1
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
(Take BEST in any way you like!)
Ray Cannon
Ray Cannon
Please excuse any smelling pisstakes.
Please excuse any smelling pisstakes.
-
ray - Posts: 221
- Joined: Wed Feb 24, 2010 12:24 am
- Location: Blackwater, Camberley. UK
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.
Now the determinants.
On the right hand side I have put the values calculated in J using extended precision (exact) arithmetic.
- Code: Select all
H←{÷1+∘.+⍨⍳⍵} ⍝ Hilbert matrix of order ⍵
H 5
1 0.5 0.333333 0.25 0.2
0.5 0.333333 0.25 0.2 0.166667
0.333333 0.25 0.2 0.166667 0.142857
0.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 det
saved ...
¯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: 238
- Joined: Thu Jul 28, 2011 10:53 am
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group