Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Cholesky-decomposition/Tcl/cholesky-decomposition-1.tcl
Normal file
19
Task/Cholesky-decomposition/Tcl/cholesky-decomposition-1.tcl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
proc cholesky a {
|
||||
set m [llength $a]
|
||||
set n [llength [lindex $a 0]]
|
||||
set l [lrepeat $m [lrepeat $n 0.0]]
|
||||
for {set i 0} {$i < $m} {incr i} {
|
||||
for {set k 0} {$k < $i+1} {incr k} {
|
||||
set sum 0.0
|
||||
for {set j 0} {$j < $k} {incr j} {
|
||||
set sum [expr {$sum + [lindex $l $i $j] * [lindex $l $k $j]}]
|
||||
}
|
||||
lset l $i $k [expr {
|
||||
$i == $k
|
||||
? sqrt([lindex $a $i $i] - $sum)
|
||||
: (1.0 / [lindex $l $k $k] * ([lindex $a $i $k] - $sum))
|
||||
}]
|
||||
}
|
||||
}
|
||||
return $l
|
||||
}
|
||||
13
Task/Cholesky-decomposition/Tcl/cholesky-decomposition-2.tcl
Normal file
13
Task/Cholesky-decomposition/Tcl/cholesky-decomposition-2.tcl
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
set test1 {
|
||||
{25 15 -5}
|
||||
{15 18 0}
|
||||
{-5 0 11}
|
||||
}
|
||||
puts [cholesky $test1]
|
||||
set test2 {
|
||||
{18 22 54 42}
|
||||
{22 70 86 62}
|
||||
{54 86 174 134}
|
||||
{42 62 134 106}
|
||||
}
|
||||
puts [cholesky $test2]
|
||||
Loading…
Add table
Add a link
Reference in a new issue