Changeset a62df64 in tol
- Timestamp:
- Nov 27, 2009, 7:34:10 PM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 1593d006
- Parents:
- 972bf92
- File:
-
- 1 edited
-
tol_pkg/MulVarFunAprox/test/test_0001/test.tol (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol_pkg/MulVarFunAprox/test/test_0001/test.tol
r972bf92 ra62df64 14 14 15 15 //Random seed setting 16 Real PutRandomSeed( 0);16 Real PutRandomSeed(234234); 17 17 Real rndSeed = GetRandomSeed(0); 18 18 WriteLn("Current Random Seed = "<<rndSeed); 19 19 20 #Require MulVarFunAprox;20 //#Require MulVarFunAprox; 21 21 //#Embed "../../../_embed_all.tol"; 22 #Embed "../../MulVarFunAprox.tol"; 22 23 23 24 Real n = 2; 24 25 25 26 Set Base.VFun = {SetOfCode( 27 VMatrix p00 (VMatrix x) { Rand(VRows(x),1,1,1) }, 28 VMatrix p10 (VMatrix x) { SubCol(x,[[1]]) }, 29 VMatrix p01 (VMatrix x) { SubCol(x,[[2]]) }, 30 VMatrix p20 (VMatrix x) { RPow(SubCol(x,[[1]]),2) }, 31 VMatrix p02 (VMatrix x) { RPow(SubCol(x,[[2]]),2) }, 32 VMatrix p11 (VMatrix x) { SubCol(x,[[1]])$*SubCol(x,[[2]]) } 33 )}; 34 35 Set Base.VDerFst = {[[ 36 {SetOfCode( 37 VMatrix p00 (VMatrix x) { Rand(VRows(x),1,0,0) }, 38 VMatrix p10 (VMatrix x) { Rand(VRows(x),1,1,1) }, 39 VMatrix p01 (VMatrix x) { Rand(VRows(x),1,0,0) }, 40 VMatrix p20 (VMatrix x) { SubCol(x,[[1]])*2 }, 41 VMatrix p02 (VMatrix x) { Rand(VRows(x),1,0,0) }, 42 VMatrix p11 (VMatrix x) { SubCol(x,[[2]]) } 43 )}; 44 {SetOfCode( 45 VMatrix p00 (VMatrix x) { Rand(VRows(x),1,0,0) }, 46 VMatrix p10 (VMatrix x) { Rand(VRows(x),1,0,0) }, 47 VMatrix p01 (VMatrix x) { Rand(VRows(x),1,1,1) }, 48 VMatrix p20 (VMatrix x) { Rand(VRows(x),1,0,0) }, 49 VMatrix p02 (VMatrix x) { SubCol(x,[[2]])*2 }, 50 VMatrix p11 (VMatrix x) { SubCol(x,[[1]]) } 51 )} 52 ]]}; 53 54 Set Base.VDerSnd = {[[ 55 {[[ 56 {SetOfCode( 57 VMatrix p00 (VMatrix x) { Rand(VRows(x),1,0,0) }, 58 VMatrix p10 (VMatrix x) { Rand(VRows(x),1,0,0) }, 59 VMatrix p01 (VMatrix x) { Rand(VRows(x),1,0,0) }, 60 VMatrix p20 (VMatrix x) { Rand(VRows(x),1,2,2) }, 61 VMatrix p02 (VMatrix x) { Rand(VRows(x),1,0,0) }, 62 VMatrix p11 (VMatrix x) { Rand(VRows(x),1,0,0) } 63 )}; 64 {SetOfCode( 65 VMatrix p00 (VMatrix x) { Rand(VRows(x),1,0,0) }, 66 VMatrix p10 (VMatrix x) { Rand(VRows(x),1,0,0) }, 67 VMatrix p01 (VMatrix x) { Rand(VRows(x),1,0,0) }, 68 VMatrix p20 (VMatrix x) { Rand(VRows(x),1,0,0) }, 69 VMatrix p02 (VMatrix x) { Rand(VRows(x),1,0,0) }, 70 VMatrix p11 (VMatrix x) { Rand(VRows(x),1,1,1) } 71 )} 72 ]]}, 73 {[[ 74 {SetOfCode( 75 VMatrix p00 (VMatrix x) { Rand(VRows(x),1,0,0) }, 76 VMatrix p10 (VMatrix x) { Rand(VRows(x),1,0,0) }, 77 VMatrix p01 (VMatrix x) { Rand(VRows(x),1,0,0) }, 78 VMatrix p20 (VMatrix x) { Rand(VRows(x),1,0,0) }, 79 VMatrix p02 (VMatrix x) { Rand(VRows(x),1,0,0) }, 80 VMatrix p11 (VMatrix x) { Rand(VRows(x),1,1,1) } 81 )}; 82 {SetOfCode( 83 VMatrix p00 (VMatrix x) { Rand(VRows(x),1,0,0) }, 84 VMatrix p10 (VMatrix x) { Rand(VRows(x),1,0,0) }, 85 VMatrix p01 (VMatrix x) { Rand(VRows(x),1,0,0) }, 86 VMatrix p20 (VMatrix x) { Rand(VRows(x),1,0,0) }, 87 VMatrix p02 (VMatrix x) { Rand(VRows(x),1,2,2) }, 88 VMatrix p11 (VMatrix x) { Rand(VRows(x),1,0,0) } 89 )} 90 ]]} ]]}; 91 92 Real K = Card(Base.VFun); 93 94 /* */ 95 96 Real J = K*100; 26 Real maxDeg = 4; 27 28 29 MulVarFunAprox::@BaseC2FunRn2R.Monomial base = 30 MulVarFunAprox::@BaseC2FunRn2R.Monomial::New(n,maxDeg); 31 32 Real K = base::_.K; 33 Real J = K*1000; 97 34 98 35 VMatrix X = Group("ConcatColumns",For(1,n,VMatrix(Real i) … … 123 60 VMatrix Fx = fun.eval.extra.base(X); 124 61 125 Real lengthRatio = 1*(J/(K*n))^(1/n);62 Real lengthRatio = 0.5*(J/(K*n))^(1/n); 126 63 127 64 Set X.col.info = For(1,n,Set(Real i) … … 261 198 Matrix QX.triplet = Group("ConcatRows", For(1,X.maxNeighbour,Matrix(Real i) 262 199 { 263 VMatrix X.hiK = (SubCol(X.h,[[i]])-1)*K; 200 VMatrix w.i = X.weight[i]; 201 Set sel.rows = MatQuery::SelectMatch(NE(Drop(Abs(w.i),1.E-15),w.i*0)); 202 VMatrix wi = SubRow(w.i,sel.rows); 203 VMatrix X.hiK = SubRow((SubCol(X.h,[[i]])-1)*K,sel.rows); 204 VMatrix Xdif.i = SubRow(X.dif[i],sel.rows); 205 VMatrix X.j.i = SubRow(X.j,sel.rows); 264 206 Group("ConcatRows", For(1,K,Matrix(Real k) 265 207 { 266 Code bvf = Base.VFun[k]; 267 VMatrix pk = bvf(X.dif[i]); 268 VMatrix qk = X.weight[i]$*pk; 269 Set sel.rows = MatQuery::SelectMatch(NE(Drop(Abs(qk),1.E-15),qk*0)); 270 VMat2Mat( 271 SubRow(X.j,sel.rows) | 272 (SubRow(X.hiK,sel.rows)+k) | 273 SubRow(qk,sel.rows)) 208 VMatrix pk = base::function.v(k,Xdif.i); 209 VMatrix qk = wi$*pk; 210 VMat2Mat(X.j.i | (X.hiK+k) | qk) 274 211 })) 275 212 })); 276 213 277 214 VMatrix QX = Pack(Convert(Triplet(QX.triplet, J, N),"Cholmod.R.Sparse")); 215 278 216 279 217 VMatrix displ.Z.1 = … … 317 255 318 256 Real Z.maxNeighbour = If(Mz,2,0); 319 VMatrix Z. j=DifEq(1/(1-B),Rand(T,1,1,1));257 VMatrix Z.t=DifEq(1/(1-B),Rand(T,1,1,1)); 320 258 321 259 VMatrix Z.h=Z.h.1 | Z.h.2; … … 340 278 { 341 279 VMatrix Z.hiK = (SubCol(Z.h,[[i]])-1)*K; 280 VMatrix Zdif.i = Z.dif[i]; 281 VMatrix Z.t.i = Z.t; 342 282 Group("ConcatRows", For(1,K,Matrix(Real k) 343 283 { 344 284 Real cumRows = 0; 345 Code bvf = Base.VFun[k]; 346 VMatrix pk = bvf(Z.dif[i])*If(i==1,+1,-1); 347 Set sel.rows = MatQuery::SelectMatch(NE(Drop(Abs(pk),1.E-15),pk*0)); 348 VMatrix col.idx = (SubRow(Z.hiK,sel.rows)+k); 285 VMatrix pk = base::function.v(k,Zdif.i)*If(i==1,+1,-1); 286 VMatrix col.idx = (Z.hiK+k); 349 287 { 350 VMatrix row.idx = SubRow(Z.j,sel.rows)+cumRows;288 VMatrix row.idx = Z.t.i+cumRows; 351 289 Real cumRows := cumRows + T; 352 VMat2Mat(row.idx | col.idx | SubRow(pk,sel.rows))290 VMat2Mat(row.idx | col.idx | pk) 353 291 } << If(prior.Z.order<1,Rand(0,3,0,0), 354 292 Group("ConcatRows",For(1,n,Matrix(Real d) 355 293 { 356 Code bvfd = Base.VDerFst[d][k];357 VMatrix pkd = b vfd(Z.dif[i])*If(i==1,+1/2,-1/2);358 VMatrix row.idx = SubRow(Z.j,sel.rows)+cumRows;294 Real sign = If(i==1,+1/2,-1/2); 295 VMatrix pkd = base::partial.derivative.1.v(k,Zdif.i,d)*sign; 296 VMatrix row.idx = Z.t.i+cumRows; 359 297 Real cumRows := cumRows + T; 360 VMat2Mat(row.idx | col.idx | SubRow(pkd,sel.rows))298 VMat2Mat(row.idx | col.idx | pkd) 361 299 })))<< If(prior.Z.order<2,Rand(0,3,0,0), 362 300 Group("ConcatRows",For(1,n,Matrix(Real d1) … … 364 302 Group("ConcatRows",For(d1,n,Matrix(Real d2) 365 303 { 366 Code bvfd2 = Base.VDerSnd[d1][d2][k];367 VMatrix pkd2 = b vfd2(Z.dif[i])*If(i==1,+1/4,-1/4);368 VMatrix row.idx = SubRow(Z.j,sel.rows)+cumRows;304 Real sign = If(i==1,+1/4,-1/4); 305 VMatrix pkd2 = base::partial.derivative.2.v(k,Zdif.i,d1,d2)*sign; 306 VMatrix row.idx = Z.t.i+cumRows; 369 307 Real cumRows := cumRows + T; 370 VMat2Mat(row.idx | col.idx | SubRow(pkd2,sel.rows))308 VMat2Mat(row.idx | col.idx | pkd2) 371 309 })) 372 310 }))) … … 377 315 Real M = J+Mz; 378 316 379 VMatrix PZ = Pack(Convert(Triplet(PZ.triplet, Mz, N),"Cholmod.R.Sparse"));317 VMatrix PZ = Convert(Triplet(PZ.triplet, Mz, N),"Cholmod.R.Sparse"); 380 318 381 319 VMatrix Fz = Rand(Mz,1,0,0);
Note: See TracChangeset
for help on using the changeset viewer.
