Changeset 7dd69db in tol for tol_pkg/FunRn2R/BaseC2.LinComb.tol
- Timestamp:
- Jan 5, 2010, 7:27:53 PM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- c62037e
- Parents:
- a693055
- File:
-
- 1 edited
-
tol_pkg/FunRn2R/BaseC2.LinComb.tol (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol_pkg/FunRn2R/BaseC2.LinComb.tol
ra693055 r7dd69db 34 34 35 35 //////////////////////////////////////////////////////////////////////////// 36 Static Text _.autodoc.member. Compact.Ratio= "Creates an instance of "37 "@BaseC2.LinComb that is close to be orthonormal and has at least"38 " the specified ratio of information of original base";39 Static @BaseC2.LinComb Compact.Ratio(36 Static Text _.autodoc.member.Orthogonal = "Creates an instance of " 37 "@BaseC2.LinComb that is orthonormal for given points and has exactly K " 38 "elements"; 39 Static @BaseC2.LinComb Orthogonal( 40 40 @BaseC2 base, 41 Real informationRatio) 41 Real K, 42 VMatrix u) 42 43 //////////////////////////////////////////////////////////////////////////// 43 44 { 44 Real K1 = base::_.K;45 46 VMatrix u = Rand(K1*10, K1, -1, 1);47 48 VMatrix Pu = Group("ConcatColumns", For(1, K1, VMatrix(Real k)49 {50 base::function.v(k,u)51 }));52 53 Set Pu.svd = SVD(VMat2Mat(Pu));54 55 Matrix Pu.eigenvalue = Tra(SubDiag(Pu.svd[2],0));56 Matrix Pu.eigenvalueCum =57 {58 Matrix aux = DifEq(1/(1-B),Pu.eigenvalue);59 aux*(1/MatSum(Pu.eigenvalue))60 };61 Matrix ratio = Rand(K1,1,informationRatio,informationRatio);62 Real K = MatSum(LE(Pu.eigenvalueCum,ratio));63 Set range.K = Range(1,K,1);64 VMatrix V = Mat2VMat(SubCol(Pu.svd[3],range.K));65 VMatrix D = Eye(K,K,0,RPow(Mat2VMat(SubRow(Pu.eigenvalue,range.K)),+1));66 VMatrix Di = Eye(K,K,0,RPow(Mat2VMat(SubRow(Pu.eigenvalue,range.K)),-1));67 VMatrix W = V*Di;68 VMatrix Wi = D*Tra(V);69 New(base, W, Wi)70 };71 72 ////////////////////////////////////////////////////////////////////////////73 Static Text _.autodoc.member.Compact.K = "Creates an instance of "74 "@BaseC2.LinComb that is close to be orthonormal and has exactly K "75 "elements";76 Static @BaseC2.LinComb Compact.K(77 @BaseC2 base,78 Real K)79 ////////////////////////////////////////////////////////////////////////////80 {81 Set aux = [[82 45 Set range.K = Range(1,K,1); 83 46 Real n = base::_.n; 84 47 Real K1 = base::_.K; 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 48 Real base::upgrade.cache(u,0,0); 90 49 VMatrix Pu = Group("ConcatColumns", For(1, K1, VMatrix(Real k) … … 100 59 VMatrix Di = Eye(K,K,0,RPow(Mat2VMat(SubRow(Pu.eigenvalue,range.K)),-1)); 101 60 VMatrix W = V*Di; 102 VMatrix Wi = D*Tra(V) ]];61 VMatrix Wi = D*Tra(V); 103 62 @BaseC2.LinComb new = New(base, W, Wi); 104 Set new::_.aux := aux; 63 Set new::_.aux := 64 [[ 65 K,n,K1,u,Pu,Pu.svd,Pu.eigenvalue,V,D,Di,W,Wi 66 ]]; 105 67 new 68 }; 69 70 //////////////////////////////////////////////////////////////////////////// 71 Static Text _.autodoc.member.Orthogonal.Rand = "Creates an instance of " 72 "@BaseC2.LinComb that is orthonormal for random points and has exactly K " 73 "elements"; 74 Static @BaseC2.LinComb Orthogonal.Rand( 75 @BaseC2 base, 76 Real K) 77 //////////////////////////////////////////////////////////////////////////// 78 { 79 Orthogonal(base,K,Gaussian(10*base::_.K, base::_.n, 0, 1)) 106 80 }; 107 81
Note: See TracChangeset
for help on using the changeset viewer.
