A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
15
Task/Matrix-arithmetic/Tcl/matrix-arithmetic-1.tcl
Normal file
15
Task/Matrix-arithmetic/Tcl/matrix-arithmetic-1.tcl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package require math::linearalgebra
|
||||
package require struct::list
|
||||
|
||||
proc permanent {matrix} {
|
||||
for {set plist {};set i 0} {$i<[llength $matrix]} {incr i} {
|
||||
lappend plist $i
|
||||
}
|
||||
foreach p [::struct::list permutations $plist] {
|
||||
foreach i $plist j $p {
|
||||
lappend prod [lindex $matrix $i $j]
|
||||
}
|
||||
lappend sum [::tcl::mathop::* {*}$prod[set prod {}]]
|
||||
}
|
||||
return [::tcl::mathop::+ {*}$sum]
|
||||
}
|
||||
8
Task/Matrix-arithmetic/Tcl/matrix-arithmetic-2.tcl
Normal file
8
Task/Matrix-arithmetic/Tcl/matrix-arithmetic-2.tcl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
set mat {
|
||||
{1 2 3 4}
|
||||
{4 5 6 7}
|
||||
{7 8 9 10}
|
||||
{10 11 12 13}
|
||||
}
|
||||
puts [::math::linearalgebra::det $mat]
|
||||
puts [permanent $mat]
|
||||
Loading…
Add table
Add a link
Reference in a new issue