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]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue