- Timestamp:
- Dec 15, 2009, 5:39:55 PM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 8fd1737
- Parents:
- 8642d7e
- Location:
- tol_pkg/FunRn2R
- Files:
-
- 7 edited
-
BaseC2.Cache.tol (modified) (4 diffs)
-
BaseC2.Eval.tol (modified) (4 diffs)
-
BaseC2.LinComb.tol (modified) (5 diffs)
-
BaseC2.Monomial.tol (modified) (2 diffs)
-
BaseC2.tol (modified) (2 diffs)
-
FunC2.tol (modified) (3 diffs)
-
test/test_0001/test.tol (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tol_pkg/FunRn2R/BaseC2.Cache.tol
r8642d7e rdac8deb 17 17 Set _.partial.derivative.1 = Copy(Empty); 18 18 Set _.partial.derivative.2 = Copy(Empty); 19 Set _.partial.integrate.1 = Copy(Empty); 19 20 20 21 //Returns the cached value of the k-th basic function for an … … 37 38 Real j_ = Min(i,j); 38 39 SubCol(_.partial.derivative.2[i_][j_],[[k]]) 40 }; 41 //Returns the cached value of the first partial integration of k-th basic 42 //function for an array of points given as the rows of a matrix 43 VMatrix partial.integrate.1.v(Real k, VMatrix X, Real i) 44 { 45 SubCol(_.partial.integrate.1[i],[[k]]) 39 46 }; 40 47 … … 62 69 }; 63 70 71 //Evaluates the first partial integration of all basic functions, one in 72 //each returned column, for an array of points given as the rows of a 73 //matrix 74 VMatrix partial.integrate.1.m(VMatrix X, Real i) 75 { 76 _.partial.integrate.1[i] 77 }; 64 78 //Some bases are more efficient using cache 65 Real _build.cache(VMatrix X, Real order)79 Real _build.cache(VMatrix X, Real deriv.order, Real integ.order) 66 80 { 67 VMatrix If(order>=0, { _.function.r := 68 _build.function.m(X) 69 }); 70 Set If(order>=1, { _.partial.derivative.1 := 81 VMatrix _.function := _build.function.m(X); 82 Set If(deriv.order>=1, { _.partial.derivative.1 := 71 83 For(1, _.n, VMatrix(Real i) 72 84 { _build.partial.derivative.1.m(X,i) }) 73 85 }); 74 Set If( order>=2, { _.partial.derivative.2 :=86 Set If(deriv.order>=2, { _.partial.derivative.2 := 75 87 For(1, _.n, Set(Real i) 76 88 { … … 81 93 }) 82 94 }); 95 Set If(integ.order>=1, { _.partial.integrate.1 := 96 For(1, _.n, VMatrix(Real i) 97 { _build.partial.integrate.1.m(X,i) }) 98 }); 83 99 True 84 100 } -
tol_pkg/FunRn2R/BaseC2.Eval.tol
r8642d7e rdac8deb 37 37 Real upgrade.cache(VMatrix X) 38 38 { 39 _.base::upgrade.cache(X,0 )39 _.base::upgrade.cache(X,0,0) 40 40 } 41 41 }; … … 62 62 Real upgrade.cache(VMatrix X) 63 63 { 64 _.base::upgrade.cache(X,1 )64 _.base::upgrade.cache(X,1,0) 65 65 } 66 66 }; … … 89 89 Real upgrade.cache(VMatrix X) 90 90 { 91 _.base::upgrade.cache(X, 1)91 _.base::upgrade.cache(X,2,0) 92 92 } 93 93 }; … … 111 111 { 112 112 _.base::partial.1ntegrate.1.m(X, _.s) 113 }; 114 Real upgrade.cache(VMatrix X) 115 { 116 _.base::upgrade.cache(X,0,1) 113 117 } 114 118 }; -
tol_pkg/FunRn2R/BaseC2.LinComb.tol
r8642d7e rdac8deb 16 16 VMatrix _.V; 17 17 VMatrix _.Vi; 18 Set _.aux = Copy(Empty); 18 19 19 20 //////////////////////////////////////////////////////////////////////////// 20 21 Static Text _.autodoc.member.New = "Creates an instance B2 of " 21 22 "@BaseC2.LinComb as B2 = B1*V"; 22 Static @BaseC2.LinComb New(@BaseC2 B1, VMatrix V, VMatrix Vi)23 Static @BaseC2.LinComb New(@BaseC2 base, VMatrix V, VMatrix Vi) 23 24 //////////////////////////////////////////////////////////////////////////// 24 25 { 25 Real n = B1::_.n; 26 26 Real n = base::_.n; 27 27 @BaseC2.LinComb aux = [[ 28 Real _.n = B1::_.n;28 Real _.n = base::_.n; 29 29 Real _.K = VColumns(V); 30 30 @BaseC2 _.base = base; … … 79 79 //////////////////////////////////////////////////////////////////////////// 80 80 { 81 Set aux = [[ 81 82 Set range.K = Range(1,K,1); 83 Real n = base::_.n; 82 84 Real K1 = base::_.K; 83 85 84 VMatrix u = Rand(K1*10, K1, -1, 1); 85 86 VMatrix u = Gaussian(K1, n, 0, 1); 87 //VMatrix u = Eye(K1,n); 88 //WriteLn("TRACE [@BaseC2.LinComb Compact.K] u:"<<u); 89 Real base::upgrade.cache(u,0,0); 86 90 VMatrix Pu = Group("ConcatColumns", For(1, K1, VMatrix(Real k) 87 91 { 88 92 base::function.v(k,u) 89 93 })); 90 94 //WriteLn("TRACE [@BaseC2.LinComb Compact.K] Pu:"<<Pu); 91 95 Set Pu.svd = SVD(VMat2Mat(Pu)); 92 96 … … 96 100 VMatrix Di = Eye(K,K,0,RPow(Mat2VMat(SubRow(Pu.eigenvalue,range.K)),-1)); 97 101 VMatrix W = V*Di; 98 VMatrix Wi = D*Tra(V); 99 New(base, W, Wi) 102 VMatrix Wi = D*Tra(V) ]]; 103 @BaseC2.LinComb new = New(base, W, Wi); 104 Set new::_.aux := aux; 105 new 100 106 }; 101 107 102 108 //////////////////////////////////////////////////////////////////////////// 103 Real _build.cache(VMatrix X, Real order)109 Real _build.cache(VMatrix X, Real deriv.order, Real integ.order) 104 110 //////////////////////////////////////////////////////////////////////////// 105 111 { 106 Real _.base::upgrade.cache(X,order); 107 VMatrix If(order>=0, { _.function := 108 _.base::function.m(X)*_.V 109 }); 110 Set If(order>=1, { _.partial.derivative.1 := 112 Real _.base::upgrade.cache(X,deriv.order,integ.order); 113 VMatrix _.function := _.base::function.m(X)*_.V; 114 Set If(deriv.order>=1, { _.partial.derivative.1 := 111 115 For(1, _.n, VMatrix(Real i) 112 116 { … … 114 118 }) 115 119 }); 116 Set If( order>=2, { _.partial.derivative.2 :=120 Set If(deriv.order>=2, { _.partial.derivative.2 := 117 121 For(1, _.n, Set(Real i) 118 122 { … … 123 127 }) 124 128 }); 129 Set If(integ.order>=1, { _.partial.integrate.1 := 130 For(1, _.n, VMatrix(Real i) 131 { 132 _.base::partial.integrate.1.m(X,i)*_.V 133 }) 134 }); 125 135 True 126 136 } -
tol_pkg/FunRn2R/BaseC2.Monomial.tol
r8642d7e rdac8deb 9 9 "functions R^n -> R . Linear independence is ensured since distinct " 10 10 "monomials are allways independent\n"; 11 Class @BaseC2.Monomial : @BaseC211 Class @BaseC2.Monomial : @BaseC2.Cache 12 12 ////////////////////////////////////////////////////////////////////////////// 13 13 { … … 65 65 //////////////////////////////////////////////////////////////////////////// 66 66 { 67 //WriteLn("TRACE @BaseC2.Monomial::_build.function. 2.v");67 //WriteLn("TRACE @BaseC2.Monomial::_build.function.v"); 68 68 BinGroup("$*", For(1,_.n, VMatrix(Real i) 69 69 { 70 RPow(SubCol(X,[[i]]),_.degComb[k][i]) 70 Real d = _.degComb[k][i]; 71 If(d==0, Rand(VRows(X),1,1,1), 72 { 73 //WriteLn(" _.degComb["<<k+"]["<<i+"]="<<_.degComb[k][i]); 74 RPow(SubCol(X,[[i]]),_.degComb[k][i]) 75 }) 71 76 })) 72 77 }; -
tol_pkg/FunRn2R/BaseC2.tol
r8642d7e rdac8deb 101 101 }; 102 102 //Some bases are more efficient using cache 103 Real _build.cache(VMatrix X, Real order) { False };103 Real _build.cache(VMatrix X, Real deriv.order, Real integ.order) { False }; 104 104 105 105 //////////////////////////////////////////////////////////////////////////// … … 169 169 }; 170 170 //Some bases are more efficient using cache 171 Real upgrade.cache(VMatrix X, Real order)172 { _build.cache(X, order) }171 Real upgrade.cache(VMatrix X, Real deriv.order, Real integ.order) 172 { _build.cache(X, deriv.order, integ.order) } 173 173 }; -
tol_pkg/FunRn2R/FunC2.tol
r8642d7e rdac8deb 77 77 //////////////////////////////////////////////////////////////////////////// 78 78 { 79 Real _.base::upgrade.cache(X,0,0); 79 80 _.base::function.m(X)*_.linComb 80 81 }; … … 83 84 //////////////////////////////////////////////////////////////////////////// 84 85 { 86 Real _.base::upgrade.cache(X,1,0); 85 87 _.base::partial.derivative.1.m(X,i)*_.linComb 86 88 }; … … 89 91 //////////////////////////////////////////////////////////////////////////// 90 92 { 93 Real _.base::upgrade.cache(X,2,0); 91 94 _.base::partial.derivative.2.m(X,i,j)*_.linComb 95 }; 96 //////////////////////////////////////////////////////////////////////////// 97 VMatrix eval.partial.integrate.1.v(VMatrix X, Real i) 98 //////////////////////////////////////////////////////////////////////////// 99 { 100 Real _.base::upgrade.cache(X,1,0); 101 _.base::partial.integrate.1.m(X,i)*_.linComb 92 102 } 103 93 104 }; 94 105 -
tol_pkg/FunRn2R/test/test_0001/test.tol
r8642d7e rdac8deb 48 48 FunRn2R::@FunC2 f2 = FunRn2R::@FunC2.InBaseC2::New(B2, u2); 49 49 50 Real B2::upgrade.cache(X,0 );50 Real B2::upgrade.cache(X,0,0); 51 51 52 52 VMatrix F2 = f2::eval.function.v(X);
Note: See TracChangeset
for help on using the changeset viewer.
