Changeset b050cc43 in tol for tol_pkg/MulVarFunAprox/DesignC2.tol
- Timestamp:
- Dec 4, 2009, 4:44:16 PM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 4bd88af
- Parents:
- fabac4a
- File:
-
- 1 edited
-
tol_pkg/MulVarFunAprox/DesignC2.tol (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol_pkg/MulVarFunAprox/DesignC2.tol
rfabac4a rb050cc43 28 28 Real _.X.maxNeighbour = ?; 29 29 Real _.Z.maxNeighbour = ?; 30 VMatrix _.Y = Rand(0,0,0,0); 31 Real _.H = ?; 32 VMatrix _.Z = Rand(0,0,0,0); 33 VMatrix _.Z.h = Rand(0,0,0,0); 34 Real _.T = ?; 35 Real _.Mz = ?; 36 Real _.M = ?; 37 Real _.K = ?; 38 Real _.N = ?; 30 VMatrix _.Y = Rand(0,2,0,0); 31 VMatrix _.Z = Rand(0,2,0,0); 32 VMatrix _.Z.h = Rand(0,1,0,0); 33 VMatrix _.B = Rand(0,2,0,0); 34 VMatrix _.B.h = Rand(0,0,0,0); 35 Real _.K = 0; 36 Real _.H = 0; 37 Real _.Tz = 0; 38 Real _.Mz = 0; 39 Real _.Tb = 0; 40 Real _.Mb = 0; 41 Real _.M = 0; 42 Real _.N = 0; 39 43 Set _.base = Copy(Empty); 40 44 Real _.base.sel = ?; 41 45 VMatrix _.QX = Rand(0,0,0,0); 46 VMatrix _.QB = Rand(0,0,0,0); 42 47 VMatrix _.PZ = Rand(0,0,0,0); 43 48 VMatrix _.Q = Rand(0,0,0,0); 44 49 VMatrix _.LQ = Rand(0,0,0,0); 45 50 VMatrix _.Q.nonNullCellsByColumns = Rand(0,0,0,0); 46 51 ////////////////////////////////////////////////////////////////////////////// 47 52 NameBlock get.base(Real sel) … … 55 60 //Virtual methods 56 61 ////////////////////////////////////////////////////////////////////////////// 62 Real build.base(Real void); 57 63 Real build.reference.points(Real void); 58 Real build.stress.points(Real void); 59 Real build.base(Real void); 64 Real build.stress.points(Real void) { False }; 65 Real build.border.points(Real void) { False }; 66 VMatrix closest.reference.index(VMatrix X); 60 67 Set get.X.weight(Set X.dif); 61 68 VMatrix match.evaluable(VMatrix X); 62 VMatrix closest.reference.index(VMatrix X);63 69 64 70 ////////////////////////////////////////////////////////////////////////////// … … 70 76 Real build.reference.points(0); 71 77 Real build.stress.points(0); 72 Real _.M := _.J+_.Mz; 78 Real build.border.points(0); 79 Real _.M := _.J+_.Mb+_.Mz; 73 80 Real build.base(0); 74 81 Real _.N := _.H*_.K; … … 84 91 85 92 ////////////////////////////////////////////////////////////////////////////// 86 VMatrix build.obs(VMatrix X) 87 ////////////////////////////////////////////////////////////////////////////// 88 { 93 VMatrix build.obs(VMatrix X, VMatrix X.h) 94 ////////////////////////////////////////////////////////////////////////////// 95 { 96 Text _MID = "[@DesignC2::build.obs] "; 89 97 Real m = VRows(X); 90 VMatrix X.h=closest.reference.index(X); 98 WriteLn("TRACE "+_MID+"1 m="<<m); 99 If(!m, Rand(0,_.N,0,0), { 100 WriteLn("TRACE "+_MID+"2"); 101 WriteLn("TRACE "+_MID+"2"); 91 102 VMatrix X.j=DifEq(1/(1-B),Rand(m,1,1,1)); 103 WriteLn("TRACE "+_MID+"2"); 92 104 Set X.dif = For(1,_.X.maxNeighbour,VMatrix(Real i) 93 105 { … … 95 107 X - SubRow(_.Y,X.h.i) 96 108 }); 109 WriteLn("TRACE "+_MID+"2"); 97 110 Set X.weight = get.X.weight(X.dif); 111 WriteLn("TRACE "+_MID+"2"); 98 112 FunRn2R::@BaseC2 b = get.base(0); 113 WriteLn("TRACE "+_MID+"2"); 99 114 Matrix QX.triplet = Group("ConcatRows", For(1,_.X.maxNeighbour,Matrix(Real i) 100 115 { … … 114 129 })); 115 130 Pack(Convert(Triplet(QX.triplet, m, _.N),"Cholmod.R.Sparse")) 116 }; 117 ////////////////////////////////////////////////////////////////////////////// 118 VMatrix build.prior(Real void) 119 ////////////////////////////////////////////////////////////////////////////// 120 { 121 VMatrix Z.t=DifEq(1/(1-B),Rand(_.T,1,1,1)); 131 })}; 132 ////////////////////////////////////////////////////////////////////////////// 133 VMatrix build.border.prior(Real void) 134 ////////////////////////////////////////////////////////////////////////////// 135 { 136 If(!_.Tb, Rand(0,_.N,0,0), { 137 VMatrix B.t=DifEq(1/(1-B),Rand(_.Tb,1,1,1)); 138 VMatrix Y = SubRow(_.Y, VCol2Set(_.B.h)); 139 VMatrix B.dif = _.B - Y; 140 FunRn2R::@BaseC2 b = get.base(0); 141 Matrix PB.triplet = 142 { 143 VMatrix B.hK = (_.B.h-1)*_.K; 144 Real b::upgrade.cache(B.dif,prior.Z.order); 145 Real lastRow = 0; 146 Group("ConcatRows", For(1,_.K,Matrix(Real k) 147 { 148 Real cumRows = lastRow; 149 VMatrix pk = b::function.v(k,B.dif); 150 VMatrix col.idx = (B.hK+k); 151 { 152 VMatrix row.idx = B.t+cumRows; 153 Real cumRows := cumRows + _.Tb; 154 VMat2Mat(row.idx | col.idx | pk) 155 } << If(prior.Z.order<1,Rand(0,3,0,0), 156 Group("ConcatRows",For(1,_.n,Matrix(Real d) 157 { 158 VMatrix pkd = b::partial.derivative.1.v(k,B.dif,d); 159 VMatrix row.idx = B.t+cumRows; 160 Real cumRows := cumRows + _.Tb; 161 VMat2Mat(row.idx | col.idx | pkd) 162 })))<< If(prior.Z.order<2,Rand(0,3,0,0), 163 Group("ConcatRows",For(1,_.n,Matrix(Real d1) 164 { 165 Group("ConcatRows",For(1,d1,Matrix(Real d2) 166 { 167 VMatrix pkd2 = b::partial.derivative.2.v(k,B.dif,d1,d2); 168 VMatrix row.idx = B.t+cumRows; 169 Real cumRows := cumRows + _.Tb; 170 VMat2Mat(row.idx | col.idx | pkd2) 171 })) 172 }))) 173 })) 174 }; 175 Convert(Triplet(PB.triplet, _.Mb, _.N),"Cholmod.R.Sparse") 176 })}; 177 ////////////////////////////////////////////////////////////////////////////// 178 VMatrix build.stress.prior(Real void) 179 ////////////////////////////////////////////////////////////////////////////// 180 { 181 If(!_.Tz, Rand(0,_.N,0,0), { 182 VMatrix Z.t=DifEq(1/(1-B),Rand(_.Tz,1,1,1)); 122 183 123 184 Set Z.dif = For(1,_.Z.maxNeighbour,VMatrix(Real i) … … 140 201 { 141 202 VMatrix row.idx = Z.t.i+cumRows; 142 Real cumRows := cumRows + _.T ;203 Real cumRows := cumRows + _.Tz; 143 204 VMat2Mat(row.idx | col.idx | pk) 144 205 } << If(prior.Z.order<1,Rand(0,3,0,0), … … 148 209 VMatrix pkd = b::partial.derivative.1.v(k,Zdif.i,d)*sign; 149 210 VMatrix row.idx = Z.t.i+cumRows; 150 Real cumRows := cumRows + _.T ;211 Real cumRows := cumRows + _.Tz; 151 212 VMat2Mat(row.idx | col.idx | pkd) 152 213 })))<< If(prior.Z.order<2,Rand(0,3,0,0), … … 158 219 VMatrix pkd2 = b::partial.derivative.2.v(k,Zdif.i,d1,d2)*sign; 159 220 VMatrix row.idx = Z.t.i+cumRows; 160 Real cumRows := cumRows + _.T ;221 Real cumRows := cumRows + _.Tz; 161 222 VMat2Mat(row.idx | col.idx | pkd2) 162 223 })) … … 165 226 })); 166 227 Convert(Triplet(PZ.triplet, _.Mz, _.N),"Cholmod.R.Sparse") 167 } ;228 })}; 168 229 ////////////////////////////////////////////////////////////////////////////// 169 230 Real build.decomposition(Real void) 170 231 ////////////////////////////////////////////////////////////////////////////// 171 232 { 172 VMatrix _.QX := build.obs(_.X); 173 VMatrix _.PZ := build.prior(0); 174 VMatrix Q.all = _.QX << _.PZ; 175 Set Q.active = MatQuery::SelectMatch( 176 NE(Tra(Rand(1,_.M,1,1)*Abs(Q.all)),Rand(_.N,1,0,0))); 177 VMatrix _.Q := SubCol(Q.all,Q.active); 233 Text _MID = "[@DesignC2::build.decomposition] "; 234 WriteLn("TRACE "+_MID+"1"); 235 VMatrix X.h=closest.reference.index(_.X); 236 VMatrix _.QX := build.obs(_.X, X.h); 237 WriteLn("TRACE "+_MID+"2"); 238 VMatrix _.QB := build.border.prior(0); 239 WriteLn("TRACE "+_MID+"3"); 240 VMatrix _.PZ := build.stress.prior(0); 241 WriteLn("TRACE "+_MID+"4"); 242 VMatrix _.Q := _.QX << _.QB << _.PZ; 243 WriteLn("TRACE "+_MID+"7"); 244 VMatrix _.Q.nonNullCellsByColumns := 245 { 246 VMatrix aux = Tra(Rand(1,_.M,1,1)*Or(_.Q,Zeros(_.M,_.N))); 247 Group("ConcatColumns",For(1,_.K,VMatrix(Real k) 248 { 249 SubRow(aux,Range(k,_.N,_.K)) 250 })) 251 }; 252 WriteLn("TRACE "+_MID+"8"); 178 253 VMatrix _.LQ := CholeskiFactor(_.Q,"XtX"); 254 WriteLn("TRACE "+_MID+"9"); 179 255 True 180 256 }
Note: See TracChangeset
for help on using the changeset viewer.
