Changeset fa86b43 in tol for tol_pkg/MulVarFunAprox/DesignC2.tol
- Timestamp:
- Dec 23, 2009, 12:22:50 PM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 68d1346
- Parents:
- 29ef418
- File:
-
- 1 edited
-
tol_pkg/MulVarFunAprox/DesignC2.tol (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol_pkg/MulVarFunAprox/DesignC2.tol
r29ef418 rfa86b43 21 21 ////////////////////////////////////////////////////////////////////////////// 22 22 Real prior.Z.order = 2; 23 Real prior.B.order = 0;23 Real prior.B.order = 1; 24 24 Real min.contrast.surface = 3; 25 25 … … 94 94 Real _.M := _.J+_.Mb+_.Mz; 95 95 Real build.base(0); 96 Real _.N := _.H*_.K;96 Real _.N := VMatSum(_.Yn); 97 97 _.N<_.M 98 98 }; … … 116 116 If(!m, Rand(0,_.N,0,0), { 117 117 WriteLn("TRACE "+_MID+"2"); 118 VMatrix X.j=DifEq(1/(1-B),Rand(m,1,1,1)); 118 119 WriteLn("TRACE "+_MID+"3"); 119 VMatrix X.j=DifEq(1/(1-B),Rand(m,1,1,1));120 WriteLn("TRACE "+_MID+"4");121 120 Set X.dif = For(1,_.X.maxNeighbour,VMatrix(Real i) 122 121 { … … 124 123 X - SubRow(_.Y,X.h.i) 125 124 }); 125 WriteLn("TRACE "+_MID+"4"); 126 Set X.weight = get.X.weight(X.dif); 126 127 WriteLn("TRACE "+_MID+"5"); 127 Set X.weight = get.X.weight(X.dif);128 WriteLn("TRACE "+_MID+"6");128 VMatrix YnCum = DifEq(1/(1-B),_.Yn); 129 VMatrix YnCumB = Sub(SetCol([[0]])<<YnCum,1,1,_.H,1); 129 130 Matrix QX.triplet = Group("ConcatRows", For(1,_.X.maxNeighbour,Matrix(Real i) 130 131 { … … 132 133 Set sel.rows = MatQuery::SelectMatch(NE(Drop(Abs(w.i),1.E-15),w.i*0)); 133 134 VMatrix wi = SubRow(w.i,sel.rows); 134 VMatrix X.hiK = SubRow((SubCol(X.h,[[i]])-1)*_.K,sel.rows); 135 VMatrix X.hi = SubCol(X.h,[[i]]); 136 Set X.hi.set = VCol2Set(X.hi); 137 VMatrix X.hiK0 = SubRow(SubRow(YnCumB,X.hi.set),sel.rows); 138 VMatrix X.hiK1 = SubRow(SubRow(YnCum, X.hi.set),sel.rows); 135 139 VMatrix Xdif.i = SubRow(X.dif[i],sel.rows); 136 140 VMatrix X.j.i = SubRow(X.j,sel.rows); … … 140 144 VMatrix pk = eval::evaluate.v(k,Xdif.i); 141 145 VMatrix qk = wi$*pk; 142 VMat2Mat(X.j.i | (X.hiK+k) | qk) 146 VMatrix X.hik = X.hiK0+k; 147 VMatrix match = LE(X.hik,X.hiK1); 148 SubRow(VMat2Mat(X.j.i | (X.hik) | qk),MatQuery::SelectMatch(match)) 143 149 })) 144 150 })); 145 WriteLn("TRACE "+_MID+" 7");151 WriteLn("TRACE "+_MID+"6"); 146 152 Pack(Convert(Triplet(QX.triplet, m, _.N),"Cholmod.R.Sparse")) 147 153 })}; … … 172 178 Set X.weight.der = get.X.weight.partial.derivative.1(X.dif,s); 173 179 WriteLn("TRACE "+_MID+"6"); 180 VMatrix YnCum = DifEq(1/(1-B),_.Yn); 181 VMatrix YnCumB = Sub(SetCol([[0]])<<YnCum,1,1,_.H,1); 174 182 Matrix QX.triplet = Group("ConcatRows", For(1,_.X.maxNeighbour,Matrix(Real i) 175 183 { … … 178 186 VMatrix wi = SubRow(w.i,sel.rows); 179 187 VMatrix wi.der = SubRow(X.weight.der[i],sel.rows); 180 VMatrix X.hiK = SubRow((SubCol(X.h,[[i]])-1)*_.K,sel.rows); 188 VMatrix X.hi = SubCol(X.h,[[i]]); 189 Set X.hi.set = VCol2Set(X.hi); 190 VMatrix X.hiK0 = SubRow(SubRow(YnCumB,X.hi.set),sel.rows); 191 VMatrix X.hiK1 = SubRow(SubRow(YnCum, X.hi.set),sel.rows); 181 192 VMatrix Xdif.i = SubRow(X.dif[i],sel.rows); 182 193 VMatrix X.j.i = SubRow(X.j,sel.rows); … … 188 199 VMatrix pk.der = der::evaluate.v(k,Xdif.i); 189 200 VMatrix qk = wi$*pk.der+wi.der$*pk; 190 VMat2Mat(X.j.i | (X.hiK+k) | qk) 201 VMatrix X.hik = X.hiK0+k; 202 VMatrix match = LE(X.hik,X.hiK1); 203 SubRow(VMat2Mat(X.j.i | (X.hik) | qk),MatQuery::SelectMatch(match)) 191 204 })) 192 205 })); … … 204 217 VMatrix B.dif = _.B - Y; 205 218 FunRn2R::@BaseC2 b = get.base(0); 219 VMatrix YnCum = DifEq(1/(1-B),_.Yn); 220 VMatrix YnCumB = Sub(SetCol([[0]])<<YnCum,1,1,_.H,1); 206 221 Matrix PB.triplet = 207 222 { 208 VMatrix B.hK = (_.B.h-1)*_.K; 223 //VMatrix B.hK = (_.B.h-1)*_.K; 224 Set B.h.set = VCol2Set(_.B.h); 225 VMatrix B.hK0 = SubRow(YnCumB,B.h.set); 226 VMatrix B.hK1 = SubRow(YnCum, B.h.set); 227 209 228 Real b::upgrade.cache(B.dif,prior.B.order,0); 210 229 Real lastRow = 0; … … 213 232 Real cumRows = lastRow; 214 233 VMatrix pk = b::function.v(k,B.dif); 215 VMatrix col.idx = (B.hK+k); 234 VMatrix B.hk = B.hK0+k; 235 VMatrix match = LE(B.hk,B.hK1); 236 Set selRows = MatQuery::SelectMatch(match); 216 237 { 217 238 VMatrix row.idx = B.t+cumRows; 218 239 Real cumRows := cumRows + _.Tb; 219 VMat2Mat(row.idx | col.idx | pk)240 SubRow(VMat2Mat(row.idx | B.hk | pk),selRows) 220 241 } << If(prior.B.order<1,Rand(0,3,0,0), 221 242 Group("ConcatRows",For(1,_.n,Matrix(Real d) … … 224 245 VMatrix row.idx = B.t+cumRows; 225 246 Real cumRows := cumRows + _.Tb; 226 VMat2Mat(row.idx | col.idx | pkd)247 SubRow(VMat2Mat(row.idx | B.hk | pkd),selRows) 227 248 })))<< If(prior.B.order<2,Rand(0,3,0,0), 228 249 Group("ConcatRows",For(1,_.n,Matrix(Real d1) … … 233 254 VMatrix row.idx = B.t+cumRows; 234 255 Real cumRows := cumRows + _.Tb; 235 VMat2Mat(row.idx | col.idx | pkd2)256 SubRow(VMat2Mat(row.idx | B.hk | pkd2),selRows) 236 257 })) 237 258 }))) … … 252 273 }); 253 274 FunRn2R::@BaseC2 b = get.base(0); 275 VMatrix YnCum = DifEq(1/(1-B),_.Yn); 276 VMatrix YnCumB = Sub(SetCol([[0]])<<YnCum,1,1,_.H,1); 254 277 Matrix PZ.triplet = Group("ConcatRows", For(1,_.Z.maxNeighbour,Matrix(Real i) 255 278 { 256 VMatrix Z.hiK = (SubCol(_.Z.h,[[i]])-1)*_.K; 279 VMatrix Z.hi = SubCol(_.Z.h,[[i]]); 280 Set Z.hi.set = VCol2Set(Z.hi); 281 VMatrix Z.hiK0 = SubRow(YnCumB,Z.hi.set); 282 VMatrix Z.hiK1 = SubRow(YnCum, Z.hi.set); 283 257 284 VMatrix Zdif.i = Z.dif[i]; 258 285 VMatrix Z.t.i = Z.t; … … 263 290 Real cumRows = lastRow; 264 291 VMatrix pk = b::function.v(k,Zdif.i)*If(i==1,+1,-1); 265 VMatrix col.idx = (Z.hiK+k); 292 VMatrix Z.hik = Z.hiK0+k; 293 VMatrix match = LE(Z.hik,Z.hiK1); 294 Set selRows = MatQuery::SelectMatch(match); 266 295 { 267 296 VMatrix row.idx = Z.t.i+cumRows; 268 297 Real cumRows := cumRows + _.Tz; 269 VMat2Mat(row.idx | col.idx | pk)298 SubRow(VMat2Mat(row.idx | Z.hik | pk),selRows) 270 299 } << If(prior.Z.order<1,Rand(0,3,0,0), 271 300 Group("ConcatRows",For(1,_.n,Matrix(Real d) … … 275 304 VMatrix row.idx = Z.t.i+cumRows; 276 305 Real cumRows := cumRows + _.Tz; 277 VMat2Mat(row.idx | col.idx | pkd)306 SubRow(VMat2Mat(row.idx | Z.hik | pkd),selRows) 278 307 })))<< If(prior.Z.order<2,Rand(0,3,0,0), 279 308 Group("ConcatRows",For(1,_.n,Matrix(Real d1) … … 285 314 VMatrix row.idx = Z.t.i+cumRows; 286 315 Real cumRows := cumRows + _.Tz; 287 VMat2Mat(row.idx | col.idx | pkd2)316 SubRow(VMat2Mat(row.idx | Z.hik | pkd2),selRows) 288 317 })) 289 318 }))) … … 307 336 VMatrix _.Q := _.QX << _.QB << _.PZ; 308 337 WriteLn("TRACE "+_MID+"5"); 338 /* 309 339 VMatrix _.Q.nonNullCellsByColumns := 310 340 { … … 315 345 })) 316 346 }; 347 */ 317 348 WriteLn("TRACE "+_MID+"6"); 318 349 VMatrix _.LQ := CholeskiFactor(_.Q,"XtX");
Note: See TracChangeset
for help on using the changeset viewer.
