Changeset 9002d5f in tol
- Timestamp:
- Jan 6, 2010, 11:40:22 PM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- f1a9d95
- Parents:
- 43068ca
- Location:
- tol_pkg/MulVarFunAprox
- Files:
-
- 6 edited
-
DesignC2.Monomial.Spheric.Grid.tol (modified) (6 diffs)
-
DesignC2.Monomial.Spheric.MeshFree.tol (modified) (5 diffs)
-
DesignC2.Spheric.tol (modified) (5 diffs)
-
DesignC2.tol (modified) (7 diffs)
-
test/test_0001/test.tol (modified) (2 diffs)
-
test/test_0002/test.tol (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol_pkg/MulVarFunAprox/DesignC2.Monomial.Spheric.Grid.tol
r43068ca r9002d5f 52 52 { 53 53 Text _MID = "[@DesignC2.Monomial.Spheric.Grid::build.reference.points] "; 54 VMatrix _.Y := _.grid::_.Y; 54 Real _.X.maxNeighbour := 1+2*_.n; 55 Real set.reference.points(_.grid::_.Y); 55 56 VMatrix Y.h = Mat2VMat(_.grid::_.Y.h); 56 57 VMatrix _.Y.neighbourhood := Y.h | Group("ConcatColumns", … … 62 63 Set X.class = Classify(Col2Set(_.grid::point2index(_.X)),Compare); 63 64 VMatrix _.Yj := Mat2VMat(SetMat([[EvalSet(X.class,Card)]]),1); 64 Real _.X.maxNeighbour := 1+2*_.n; 65 Real _.H := _.grid::_.H 65 Real _.H 66 66 }; 67 67 … … 73 73 WriteLn("TRACE "+_MID+"1"); 74 74 Real _.Z.maxNeighbour := If(prior.Z.order>=0,2,0); 75 If(!_.Z.maxNeighbour, 76 { 77 VMatrix _.Yt := Zeros(_.H,1); 78 Real _.Tz := 0 79 },{ 80 WriteLn("TRACE "+_MID+"2.1"); 75 81 Matrix Y.neighbour.triplet = Group("ConcatRows", For(1,_.H,Matrix(Real h) 76 82 { … … 81 87 })); 82 88 83 WriteLn("TRACE "+_MID+"2 ");89 WriteLn("TRACE "+_MID+"2.2"); 84 90 VMatrix Y.neighbour.1.map = Triplet(Y.neighbour.triplet,_.H,_.H); 85 91 VMatrix Y.neighbour.2.map = Y.neighbour.1.map*Y.neighbour.1.map; … … 140 146 prior.Z.order==2, _.Tz*(1+_.n*3/2+(1/2)*_.n^2)); 141 147 _.Tz 142 } ;148 })}; 143 149 144 150 ////////////////////////////////////////////////////////////////////////////// … … 203 209 } 204 210 205 206 211 }; -
tol_pkg/MulVarFunAprox/DesignC2.Monomial.Spheric.MeshFree.tol
r43068ca r9002d5f 17 17 //Configuration parameters 18 18 ////////////////////////////////////////////////////////////////////////////// 19 MatQuery::@ANN.KDTree _.ann;20 19 Real stress.maxDistance; 21 22 //////////////////////////////////////////////////////////////////////////////23 //Auxiliar members24 //////////////////////////////////////////////////////////////////////////////25 VMatrix _.R =Rand(0,0,0,0);26 MatQuery::@KNN.Neighbourhood _.ngbh;27 20 28 21 //////////////////////////////////////////////////////////////////////////// … … 30 23 VMatrix X, 31 24 Real maxNeighbour, 32 Real stress.maxDistance_,33 Real radius.margin)25 Real radius.margin, 26 Real stress.maxDistance_) 34 27 //////////////////////////////////////////////////////////////////////////// 35 28 { … … 40 33 Real _.J = VRows(X); 41 34 Real _.X.maxNeighbour = maxNeighbour+1; 42 Real stress.maxDistance = stress.maxDistance_;43 35 Real _.radius.margin = radius.margin; 44 MatQuery::@ANN.KDTree _.ann = 45 MatQuery::@ANN.KDTree::New(VMat2Mat(X)); 46 MatQuery::@KNN.Neighbourhood _.ngbh = 47 _.ann::search(_.ann::_.X,_.X.maxNeighbour) 36 Real stress.maxDistance = stress.maxDistance_ 48 37 ]] 49 38 }; … … 54 43 { 55 44 Text _MID = "[@DesignC2.Monomial.Spheric.MeshFree::build.reference.points] "; 56 VMatrix _.Y := _.X; 57 Real _.H := VRows(_.Y); 58 VMatrix _.R := 59 Mat2VMat(Sqrt(SubCol(_.ngbh::_.distance2,[[_.X.maxNeighbour]])))* 60 (1+Min(0,_.radius.margin)); 45 Real set.reference.points(_.X); 61 46 VMatrix _.Yj := Constant(_.H,1,_.X.maxNeighbour-1); 62 47 _.H … … 136 121 VMatrix _.Yb := Zeros(_.H,1); 137 122 Real _.Tb := 0 138 };139 /*140 //////////////////////////////////////////////////////////////////////////////141 Real build.base(Real void)142 //////////////////////////////////////////////////////////////////////////////143 {144 Text _MID = "[@DesignC2.Monomial::build.base] ";145 VMatrix _.Yn :=146 Floor(Min(Rand(_.H,1,_.K0,_.K0),Max(_.Ym/min.contrast.surface,_.Ym*0+1)));147 148 Set Append(_.base, [[base.feasible]]);149 Real _.base.sel := Card(_.base);150 _.K151 };152 */153 ////////////////////////////////////////////////////////////////////////////154 VMatrix match.evaluable(VMatrix X)155 ////////////////////////////////////////////////////////////////////////////156 {157 MatQuery::@KNN.Neighbourhood ngbh =158 _.ann::search(VMat2Mat(X),1);159 VMatrix Y = SubRow(_.Y,Col2Set(ngbh::_.neighbour));160 VMatrix dist = Mat2VMat(Sqrt(ngbh::_.distance2));161 VMatrix X.h = Mat2VMat(ngbh::_.neighbour);162 LE(dist,get.radius(X.h))$*163 LE(dist,Constant(VRows(dist),1,stress.maxDistance))164 165 };166 167 //////////////////////////////////////////////////////////////////////////////168 VMatrix closest.reference.index(VMatrix X)169 //////////////////////////////////////////////////////////////////////////////170 {171 MatQuery::@KNN.Neighbourhood ngbh =172 _.ann::search(VMat2Mat(X),_.X.maxNeighbour);173 Mat2VMat(ngbh::_.neighbour)174 };175 176 //////////////////////////////////////////////////////////////////////////////177 VMatrix get.radius(VMatrix Y.idx)178 //////////////////////////////////////////////////////////////////////////////179 {180 SubRow(_.R,VCol2Set(Y.idx))181 };182 183 ///////////////////////////////////////////////////////////////////////////184 VMatrix generate.internal.points(Real m)185 ///////////////////////////////////////////////////////////////////////////186 {187 Text _MID = "[@DesignC2.Monomial.Spheric.MeshFree::generate.internal.points] ";188 WriteLn("TRACE "+_MID+"1 m="<<m);189 VMatrix h = Round(Rand(m,1,0.5,_.H+0.499999999));190 WriteLn("TRACE "+_MID+"2 h:\n"<<h);191 VMatrix y = SubRow(_.Y,VCol2Set(h));192 WriteLn("TRACE "+_MID+"3 y:\n"<<y);193 VMatrix v = Gaussian(m,_.n,0,1);194 WriteLn("TRACE "+_MID+"4 v:\n"<<v);195 VMatrix u = v*(VMatDat(MtMSqr(v),1,1)^-0.5);196 WriteLn("TRACE "+_MID+"5 u:\n"<<u);197 VMatrix rnd = get.radius(h)$*Rand(m,1,0,1);198 WriteLn("TRACE "+_MID+"5 rnd:\n"<<rnd);199 VMatrix r = Eye(m,m,0,rnd);200 WriteLn("TRACE "+_MID+"6 r:\n"<<r);201 y + r * u202 123 } 203 124 204 205 125 }; -
tol_pkg/MulVarFunAprox/DesignC2.Spheric.tol
r43068ca r9002d5f 18 18 Real _.radius.margin; 19 19 20 ////////////////////////////////////////////////////////////////////////////// 21 //Auxiliar members 22 ////////////////////////////////////////////////////////////////////////////// 23 VMatrix _.R =Rand(0,0,0,0); 24 MatQuery::@ANN.KDTree _.ann = 25 MatQuery::@ANN.KDTree::Default(0); 26 MatQuery::@KNN.Neighbourhood _.ngbh = 27 MatQuery::@KNN.Neighbourhood::Default(0); 28 20 29 ////////////////////////////////////////////////////////////////////////////// 21 // Virtual methods30 //Methods 22 31 ////////////////////////////////////////////////////////////////////////////// 23 VMatrix get.radius(VMatrix Y.idx); 32 33 ////////////////////////////////////////////////////////////////////////////// 34 Real set.reference.points(VMatrix Y) 35 ////////////////////////////////////////////////////////////////////////////// 36 { 37 VMatrix _.Y := Y; 38 Real _.H := VRows(_.Y); 39 Real _.ann::set.data(VMat2Mat(_.Y)); 40 Real _.ann::update.search(_.ann::_.X,_.X.maxNeighbour,_.ngbh); 41 VMatrix _.R := 42 Mat2VMat(Sqrt(SubCol(_.ngbh::_.distance2,[[_.X.maxNeighbour]])))* 43 (1+Min(0,_.radius.margin)); 44 True 45 }; 46 47 //////////////////////////////////////////////////////////////////////////// 48 VMatrix match.evaluable(VMatrix X) 49 //////////////////////////////////////////////////////////////////////////// 50 { 51 MatQuery::@KNN.Neighbourhood ngbh = 52 _.ann::search(VMat2Mat(X),1); 53 VMatrix dist = Mat2VMat(Sqrt(ngbh::_.distance2)); 54 VMatrix X.h = Mat2VMat(ngbh::_.neighbour); 55 LE(dist,get.radius(X.h))$* 56 LE(dist,Constant(VRows(dist),1,stress.maxDistance)) 57 }; 58 59 ////////////////////////////////////////////////////////////////////////////// 60 VMatrix closest.reference.index(VMatrix X) 61 ////////////////////////////////////////////////////////////////////////////// 62 { 63 MatQuery::@KNN.Neighbourhood ngbh = 64 _.ann::search(VMat2Mat(X),_.X.maxNeighbour); 65 Mat2VMat(ngbh::_.neighbour) 66 }; 67 68 ////////////////////////////////////////////////////////////////////////////// 69 VMatrix get.radius(VMatrix Y.idx) 70 ////////////////////////////////////////////////////////////////////////////// 71 { 72 SubRow(_.R,VCol2Set(Y.idx)) 73 }; 74 75 /////////////////////////////////////////////////////////////////////////// 76 VMatrix generate.internal.points(Real m) 77 /////////////////////////////////////////////////////////////////////////// 78 { 79 Text _MID = "[@DesignC2.Monomial.Spheric.MeshFree::generate.internal.points] "; 80 WriteLn("TRACE "+_MID+"1 m="<<m); 81 VMatrix h = Round(Rand(m,1,0.5,_.H+0.499999999)); 82 WriteLn("TRACE "+_MID+"2 h:\n"<<h); 83 VMatrix y = SubRow(_.Y,VCol2Set(h)); 84 WriteLn("TRACE "+_MID+"3 y:\n"<<y); 85 VMatrix v = Gaussian(m,_.n,0,1); 86 WriteLn("TRACE "+_MID+"4 v:\n"<<v); 87 VMatrix u = v*(VMatDat(MtMSqr(v),1,1)^-0.5); 88 WriteLn("TRACE "+_MID+"5 u:\n"<<u); 89 VMatrix rnd = get.radius(h)$*Rand(m,1,0,1); 90 WriteLn("TRACE "+_MID+"5 rnd:\n"<<rnd); 91 VMatrix r = Eye(m,m,0,rnd); 92 WriteLn("TRACE "+_MID+"6 r:\n"<<r); 93 y + r * u 94 }; 24 95 25 96 /////////////////////////////////////////////////////////////////////////// … … 28 99 { 29 100 Real m = VRows(X.dif[1]); 30 Set X.tao = For(1,_.X.maxNeighbour,VMatrix(Real i) 101 Real numNeighbour = Card(X.h); 102 Set X.tao = For(1,numNeighbour,VMatrix(Real i) 31 103 { 32 104 VMatrix X.norm2 = RPow(X.dif[i],2)*Rand(_.n,1,1,1); 33 105 RPow(X.norm2,0.5)$/get.radius(X.h[i]) 34 106 }); 35 Set X.tao2 = For(1, _.X.maxNeighbour,VMatrix(Real i)107 Set X.tao2 = For(1,numNeighbour,VMatrix(Real i) 36 108 { 37 109 RPow(X.tao[i],2) 38 110 }); 39 Set X.match = For(1, _.X.maxNeighbour,VMatrix(Real i)111 Set X.match = For(1,numNeighbour,VMatrix(Real i) 40 112 { 41 113 LE(X.tao[i],Rand(m,1,1,1)) 42 114 }); 43 Set X.lambda = For(1, _.X.maxNeighbour,VMatrix(Real i)115 Set X.lambda = For(1,numNeighbour,VMatrix(Real i) 44 116 { 45 117 RPow(X.match[i] $* (Rand(m,1,1,1)-X.tao2[i]),4) … … 47 119 VMatrix X.lambda.sum = SetSum(X.lambda); 48 120 49 For(1, _.X.maxNeighbour,VMatrix(Real i)121 For(1,numNeighbour,VMatrix(Real i) 50 122 { 51 123 X.lambda[i] $/ X.lambda.sum … … 57 129 { 58 130 Real m = VRows(X.dif[1]); 59 Set X.tao = For(1,_.X.maxNeighbour,VMatrix(Real i) 131 Real numNeighbour = Card(X.h); 132 Set X.tao = For(1,numNeighbour,VMatrix(Real i) 60 133 { 61 134 VMatrix X.norm2 = RPow(X.dif[i],2)*Rand(_.n,1,1,1); 62 135 RPow(X.norm2,0.5)$/get.radius(X.h[i]) 63 136 }); 64 Set X.tao2 = For(1, _.X.maxNeighbour,VMatrix(Real i)137 Set X.tao2 = For(1,numNeighbour,VMatrix(Real i) 65 138 { 66 139 RPow(X.tao[i],2) 67 140 }); 68 Set X.match = For(1, _.X.maxNeighbour,VMatrix(Real i)141 Set X.match = For(1,numNeighbour,VMatrix(Real i) 69 142 { 70 143 LE(X.tao[i],Rand(m,1,1,1)) 71 144 }); 72 Set X.lambda = For(1, _.X.maxNeighbour,VMatrix(Real i)145 Set X.lambda = For(1,numNeighbour,VMatrix(Real i) 73 146 { 74 147 RPow(X.match[i] $* (Rand(m,1,1,1)-X.tao2[i]),4) 75 148 }); 76 Set X.lambda.der = For(1, _.X.maxNeighbour,VMatrix(Real i)149 Set X.lambda.der = For(1,numNeighbour,VMatrix(Real i) 77 150 { 78 151 RPow(X.match[i] $* … … 83 156 VMatrix X.lambda.sum.2 = RPow(X.lambda.sum,2); 84 157 VMatrix X.lambda.der.sum = SetSum(X.lambda.der); 85 For(1, _.X.maxNeighbour,VMatrix(Real i)158 For(1,numNeighbour,VMatrix(Real i) 86 159 { 87 160 (X.lambda.der[i]$*X.lambda.sum-X.lambda[i]$*X.lambda.der.sum) -
tol_pkg/MulVarFunAprox/DesignC2.tol
r43068ca r9002d5f 93 93 VMatrix X.j=DifEq(1/(1-B),Rand(m,1,1,1)); 94 94 WriteLn("TRACE "+_MID+"3 X.h:\n"<<X.h); 95 Set X.h_ = For(1,_.X.maxNeighbour,VMatrix(Real i) { SubCol(X.h,[[i]]) }); 95 Real numNeighbour = VColumns(X.h); 96 Set X.h_ = For(1,numNeighbour,VMatrix(Real i) { SubCol(X.h,[[i]]) }); 96 97 WriteLn("TRACE "+_MID+"3.1"); 97 Set X.dif = For(1, _.X.maxNeighbour,VMatrix(Real i)98 Set X.dif = For(1,numNeighbour,VMatrix(Real i) 98 99 { 99 100 Set X.h.i = VCol2Set(X.h_[i]); … … 105 106 VMatrix YnCum = DifEq(1/(1-B),_.Yn); 106 107 VMatrix YnCumB = Sub(SetCol([[0]])<<YnCum,1,1,_.H,1); 107 Matrix QX.triplet = Group("ConcatRows", For(1, _.X.maxNeighbour,Matrix(Real i)108 Matrix QX.triplet = Group("ConcatRows", For(1,numNeighbour,Matrix(Real i) 108 109 { 109 110 VMatrix w.i = X.weight[i]; … … 129 130 Pack(Convert(Triplet(QX.triplet, m, _.N),"Cholmod.R.Sparse")) 130 131 })}; 132 131 133 132 134 ////////////////////////////////////////////////////////////////////////////// … … 146 148 VMatrix X.j=DifEq(1/(1-B),Rand(m,1,1,1)); 147 149 WriteLn("TRACE "+_MID+"4"); 148 Set X.h_ = For(1,_.X.maxNeighbour,VMatrix(Real i) { SubCol(X.h,[[i]]) }); 149 Set X.dif = For(1,_.X.maxNeighbour,VMatrix(Real i) 150 Real numNeighbour = VColumns(X.h); 151 Set X.h_ = For(1,numNeighbour,VMatrix(Real i) { SubCol(X.h,[[i]]) }); 152 Set X.dif = For(1,numNeighbour,VMatrix(Real i) 150 153 { 151 154 Set X.h.i = VCol2Set(X.h_[i]); … … 158 161 VMatrix YnCum = DifEq(1/(1-B),_.Yn); 159 162 VMatrix YnCumB = Sub(SetCol([[0]])<<YnCum,1,1,_.H,1); 160 Matrix QX.triplet = Group("ConcatRows", For(1, _.X.maxNeighbour,Matrix(Real i)163 Matrix QX.triplet = Group("ConcatRows", For(1,numNeighbour,Matrix(Real i) 161 164 { 162 165 VMatrix w.i = X.weight[i]; … … 360 363 WriteLn("TRACE "+_MID+"6"); 361 364 VMatrix _.QtQ := MtMSqr(_.Q); 362 VMatrix _.LQ := CholeskiFactor(_.QtQ,"X",False,False); 365 VMatrix _.LQ := CholeskiFactor(_.Q,"XtX"); 366 /* 367 VMatrix _.LQ := CholeskiFactor(_.QtQ,"X",False,True); 363 368 Real iter = 1; 364 369 Real lambda = 1.e-15; … … 366 371 { 367 372 VMatrix _.QtQ := _.QtQ + Eye(_.N,_.N,0,lambda); 368 VMatrix _.LQ := CholeskiFactor(_.QtQ,"X",False, False);373 VMatrix _.LQ := CholeskiFactor(_.QtQ,"X",False,True); 369 374 Real lambda := lambda * 2; 370 375 Real iter := iter+1 371 376 }); 372 //VMatrix _.LQ := CholeskiFactor(_.Q,"XtX"); 377 */ 373 378 WriteLn("TRACE "+_MID+"7"); 374 379 True -
tol_pkg/MulVarFunAprox/test/test_0001/test.tol
r43068ca r9002d5f 42 42 MulVarFunAprox::@DesignC2.Monomial.Spheric.Grid::New( 43 43 VMatrix X, 44 Real radius.margin = Sqrt(2)-1 ,44 Real radius.margin = Sqrt(2)-1+0.00001, 45 45 Real radius = 0.5, 46 46 Real do.build.border = False)}; … … 268 268 "); 269 269 270 Real OSCmdWait("Rgui CMD BATCH --vanilla show.R show.R.log");271 270 /* 272 271 Real numErr1 = Copy(NError); -
tol_pkg/MulVarFunAprox/test/test_0002/test.tol
r43068ca r9002d5f 33 33 })) 34 34 }; 35 VMatrix X = generate.nodal.points( 500,2);35 VMatrix X = generate.nodal.points(200,2); 36 36 /* * / 37 37 MulVarFunAprox::@DesignC2 design = { … … 44 44 VMatrix X, 45 45 Real maxNeighbour = 4*VColumns(X), 46 Real radius.margin = 0.0001; 46 47 Real stress.maxDistance_ = 5) }; 47 48 /* */
Note: See TracChangeset
for help on using the changeset viewer.
