| [6d7779d] | 1 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2 | # FILE : mattable.tcl |
|---|
| 3 | # PURPOSE : This file |
|---|
| 4 | # PURPOSE : This file contains a namespace called MatrixTable with its |
|---|
| 5 | # functions. It's for managing matrix tables. |
|---|
| 6 | # It's a child of BayesTable so inherites all its functionalities. |
|---|
| 7 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 11 | namespace eval ::MatrixTable { |
|---|
| 12 | # |
|---|
| 13 | # PURPOSE: The purpose of this namespace is organize code and functions and |
|---|
| 14 | # provides functions to create and manage a matrix object table. |
|---|
| 15 | # A special namespace is created for each instance of Matrix table. |
|---|
| 16 | # |
|---|
| 17 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 22 | proc ::MatrixTable::Create {path matrix} { |
|---|
| 23 | # |
|---|
| 24 | # PURPOSE: |
|---|
| 25 | # |
|---|
| 26 | # PARAMETERS: |
|---|
| 27 | # |
|---|
| 28 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 29 | set this [::BayesTable::Create $path\ |
|---|
| 30 | -fillproc "::MatrixTable::Fill [list $matrix]" -child MatrixTable] |
|---|
| 31 | ReadIni $this |
|---|
| 32 | Configure $this |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 37 | proc ::MatrixTable::Fill {refMatrix this} { |
|---|
| 38 | # |
|---|
| 39 | # PURPOSE: |
|---|
| 40 | # |
|---|
| 41 | # PARAMETERS: |
|---|
| 42 | # |
|---|
| 43 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 44 | set matrix [::tol::matrix $refMatrix] |
|---|
| 45 | # insert the matrix into the table |
|---|
| 46 | set numCols [lindex $matrix 2] |
|---|
| 47 | set numRows [lindex $matrix 1] |
|---|
| 48 | |
|---|
| 49 | ::BayesTable::SetElement $this 0 0 [lindex $matrix 0] |
|---|
| 50 | for {set j 0} {$j < $numCols} {incr j} { |
|---|
| 51 | ::BayesTable::SetElement $this 0 [expr $j+1] [expr $j+1] 1 |
|---|
| 52 | } |
|---|
| 53 | set lst [lindex $matrix 3] |
|---|
| 54 | for {set i 0} {$i < $numRows} {incr i} { |
|---|
| 55 | ::BayesTable::SetElement $this [expr $i+1] 0 [expr $i+1] 1 |
|---|
| 56 | for {set j 0} {$j < $numCols} {incr j} { |
|---|
| 57 | ::BayesTable::SetElement $this [expr $i+1] [expr $j+1] \ |
|---|
| 58 | [lindex $lst [expr $numCols*$i+$j]] |
|---|
| 59 | } |
|---|
| 60 | } |
|---|
| 61 | ::BayesTable::SetMatrixInfo $this\ |
|---|
| 62 | [list [expr $numRows+1] [expr $numCols+1]] "" |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 67 | # INIFILE |
|---|
| 68 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 69 | |
|---|
| 70 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 71 | proc ::MatrixTable::ReadIni {this} { |
|---|
| 72 | # |
|---|
| 73 | # PURPOSE: Reads specific options from .ini file. First of all, reads options |
|---|
| 74 | # from BayesTable. Actually there isn't specific options. |
|---|
| 75 | # |
|---|
| 76 | # PARAMETERS: |
|---|
| 77 | # this -> Instance of BayesTable |
|---|
| 78 | # |
|---|
| 79 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 80 | # General options (parent) |
|---|
| 81 | ::BayesTable::ReadIni $this |
|---|
| 82 | # Specific options |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 87 | proc ::MatrixTable::WriteIni {this} { |
|---|
| 88 | # |
|---|
| 89 | # PURPOSE: Writes specific options to .ini file. This procedure is called by |
|---|
| 90 | # parent BayesGraph. Actually doesn't do anything. |
|---|
| 91 | # |
|---|
| 92 | # PARAMETERS: |
|---|
| 93 | # this -> Instance of BayesTable |
|---|
| 94 | # |
|---|
| 95 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 96 | |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 101 | proc ::MatrixTable::Configure {this} { |
|---|
| 102 | # |
|---|
| 103 | # PURPOSE: Configures some options of Matrix Table. First of all, configures |
|---|
| 104 | # options from BayesTable. Actually there isn't specific options. |
|---|
| 105 | # |
|---|
| 106 | # PARAMETERS: |
|---|
| 107 | # this -> Instance of BayesTable |
|---|
| 108 | # |
|---|
| 109 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 110 | # General options (parent) |
|---|
| 111 | ::BayesTable::Configure $this |
|---|
| 112 | # Specific options |
|---|
| 113 | } |
|---|
| 114 | |
|---|