Changeset 59e155b in tol
- Timestamp:
- Dec 30, 2009, 6:26:50 PM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- d0fc203
- Parents:
- 4a13114
- File:
-
- 1 edited
-
tol_pkg/MulVarFunAprox/ModelC2.tol (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol_pkg/MulVarFunAprox/ModelC2.tol
r4a13114 r59e155b 13 13 @DesignC2 _.design; 14 14 VMatrix _.Fx; 15 16 ////////////////////////////////////////////////////////////////////////////// 17 //Configuration parameters 18 ////////////////////////////////////////////////////////////////////////////// 19 Real allow.MinimumResidualsSolve.Full = False; 20 Real allow.MinimumResidualsSolve.NonFull = False; 15 21 16 22 ////////////////////////////////////////////////////////////////////////////// … … 36 42 VMatrix _.Fx = Fx 37 43 ]]; 38 Real new::estimate(0);44 //Real new::estimate(0); 39 45 new 40 46 }; … … 72 78 Real t.decomposition = Copy(Time)-t0; 73 79 WriteLn("TRACE"+_MID+"Input decomposed in "<<t.decomposition+" seconds"); 74 Real t0 := Copy(Time);75 WriteLn("TRACE"+_MID+"Running regression model for design matrix "<<design::_.Q);76 80 MulVarFunAprox::@ModelC2 model = MulVarFunAprox::@ModelC2::New( 77 81 design, 78 82 Fx); 79 Real t.estimating = Copy(Time)-t0;80 WriteLn("TRACE"+_MID+"Estimated model in "<<t.estimating+" seconds");81 83 model 82 84 }; … … 86 88 ////////////////////////////////////////////////////////////////////////////// 87 89 { 90 Real t0 := Copy(Time); 91 Text _MID = "[@ModelC2::estimate] "; 92 WriteLn("TRACE"+_MID+"Running regression model for design matrix "<<design::_.Q); 88 93 VMatrix _.Fz := Rand(_.design::_.Mz,1,0,0); 89 94 VMatrix _.Fb := Rand(_.design::_.Mb,1,0,0); 90 95 VMatrix _.F := _.Fx << _.Fb << _.Fz; 91 VMatrix _.alpha := CholeskiSolve(_.design::_.LQ,Tra(Tra(_.F)*_.design::_.Q),"PtLLtP"); 96 VMatrix _.alpha := Case( 97 EQ(VRows(_.design::_.LQ),design::_.N), 98 { 99 WriteLn("TRACE"+_MID+" 3.1 CholeskiSolve"); 100 CholeskiSolve(_.design::_.LQ,Tra(Tra(_.F)*_.design::_.Q),"PtLLtP") 101 }, 102 allow.MinimumResidualsSolve.Full & (_.design::_.M>_.design::_.N), 103 { 104 WriteLn("TRACE"+_MID+" 3.2 MinimumResidualsSolve full"); 105 MinimumResidualsSolve(_.design::_.Q, _.F) 106 }, 107 allow.MinimumResidualsSolve.NonFull, 108 { 109 WriteLn("TRACE"+_MID+" 3.3 MinimumResidualsSolve non full"); 110 MinimumResidualsSolve( 111 _.design::_.Q<<Zeros(_.design::_.N-_.design::_.M,_.design::_.N), 112 _.F) 113 }, 114 1==1, 115 { 116 WriteLn(_MID+" Cannot solve linear system ","E"); 117 Rand(_.design::_.N,1,0,0) 118 }); 119 Real t.estimating = Copy(Time)-t0; 120 WriteLn("TRACE"+_MID+"Estimated model in "<<t.estimating+" seconds"); 92 121 VMatrix _.F.frc := SubRow(_.design::_.Q*_.alpha,Range(1,_.design::_.J,1)); 93 122 VMatrix _.F.cmp := _.Fx | _.F.frc; … … 100 129 101 130 ////////////////////////////////////////////////////////////////////////////// 102 VMatrix evaluate(VMatrix X )131 VMatrix evaluate(VMatrix X, Real defaultValue) 103 132 ////////////////////////////////////////////////////////////////////////////// 104 133 { 105 134 Real m = VRows(X); 106 135 VMatrix X.match = _.design::match.evaluable(X); 107 Set X. select = MatQuery::SelectMatch(X.match);108 VMatrix X.1 = SubRow(X,X. select);136 Set X.1.select = MatQuery::SelectMatch(X.match); 137 VMatrix X.1 = SubRow(X,X.1.select); 109 138 Real m.1 = VRows(X.1); 110 139 VMatrix X.1.h = _.design::closest.reference.index(X.1); 111 140 VMatrix QX.1 = _.design::build.obs(X.1, X.1.h); 112 141 VMatrix F.1 = QX.1*_.alpha; 113 Matrix triplet.1 = SetCol(X.select)|Rand(m.1,1,1,1)|VMat2Mat(F.1); 114 Pack(Convert(Triplet(triplet.1,m,1),"Cholmod.R.Sparse")) 142 Matrix triplet.1 = SetCol(X.1.select)|Rand(m.1,1,1,1)|VMat2Mat(F.1); 143 VMatrix T.1 = Pack(Convert(Triplet(triplet.1,m,1),"Cholmod.R.Sparse")); 144 If(And(!IsUnknown(defaultValue),defaultValue==0), T.1, 145 { 146 Set X.2.select = MatQuery::SelectMatch(Not(X.match)); 147 VMatrix X.2 = SubRow(X,X.2.select); 148 Real m.2 = VRows(X.2); 149 VMatrix F.2 = Constant(m.2,1,defaultValue); 150 Matrix triplet.2 = SetCol(X.2.select)|Rand(m.2,1,1,1)|VMat2Mat(F.2); 151 VMatrix T.2 = Pack(Convert(Triplet(triplet.2,m,1),"Cholmod.R.Sparse")); 152 T.1+T.2 153 }) 115 154 }; 116 155
Note: See TracChangeset
for help on using the changeset viewer.
