Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
7
Task/Identity-matrix/Tcl/identity-matrix-1.tcl
Normal file
7
Task/Identity-matrix/Tcl/identity-matrix-1.tcl
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
proc I {rank {zero 0.0} {one 1.0}} {
|
||||
set m [lrepeat $rank [lrepeat $rank $zero]]
|
||||
for {set i 0} {$i < $rank} {incr i} {
|
||||
lset m $i $i $one
|
||||
}
|
||||
return $m
|
||||
}
|
||||
13
Task/Identity-matrix/Tcl/identity-matrix-2.tcl
Normal file
13
Task/Identity-matrix/Tcl/identity-matrix-2.tcl
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package require struct::matrix
|
||||
|
||||
proc I {rank {zero 0.0} {one 1.0}} {
|
||||
set m [struct::matrix]
|
||||
$m add columns $rank
|
||||
$m add rows $rank
|
||||
for {set i 0} {$i < $rank} {incr i} {
|
||||
for {set j 0} {$j < $rank} {incr j} {
|
||||
$m set cell $i $j [expr {$i==$j ? $one : $zero}]
|
||||
}
|
||||
}
|
||||
return $m
|
||||
}
|
||||
2
Task/Identity-matrix/Tcl/identity-matrix-3.tcl
Normal file
2
Task/Identity-matrix/Tcl/identity-matrix-3.tcl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
set m [I 5 0 1] ;# Integer 0/1 for clarity of presentation
|
||||
puts [$m format 2string]
|
||||
Loading…
Add table
Add a link
Reference in a new issue