Jump to content

Cholesky decomposition: Difference between revisions

Added 11l
(Added AutoHotkey)
(Added 11l)
Line 78:
# The Cholesky decomposition of a [[Pascal matrix generation‎|Pascal]] upper-triangle matrix is the [[wp:Identity matrix|Identity matrix]] of the same size.
# The Cholesky decomposition of a Pascal symmetric matrix is the Pascal lower-triangle matrix of the same size.
 
=={{header|11l}}==
{{trans|Python}}
 
<lang 11l>F cholesky(A)
V l = [[0.0] * A.len] * A.len
L(i) 0 .< A.len
L(j) 0 .. i
V s = sum((0 .< j).map(k -> @l[@i][k] * @l[@j][k]))
l[i][j] = I (i == j) {sqrt(A[i][i] - s)} E (1.0 / l[j][j] * (A[i][j] - s))
R l
 
F pprint(m)
print(‘[’)
L(row) m
print(row)
print(‘]’)
 
V m1 = [[25, 15, -5],
[15, 18, 0],
[-5, 0, 11]]
print(cholesky(m1))
print()
 
V m2 = [[18, 22, 54, 42],
[22, 70, 86, 62],
[54, 86, 174, 134],
[42, 62, 134, 106]]
pprint(cholesky(m2))</lang>
 
{{out}}
<pre>
[[5, 0, 0], [3, 3, 0], [-1, 1, 3]]
 
[
[4.24264, 0, 0, 0]
[5.18545, 6.56591, 0, 0]
[12.7279, 3.04604, 1.64974, 0]
[9.89949, 1.62455, 1.84971, 1.39262]
]
</pre>
 
=={{header|Ada}}==
1,481

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.