- Timestamp:
- Dec 2, 2009, 5:20:39 PM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- f79532b
- Parents:
- 17d3fef
- File:
-
- 1 edited
-
tol_pkg/FunRn2R/BaseC2.LinComb.tol (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol_pkg/FunRn2R/BaseC2.LinComb.tol
r17d3fef r280293c 15 15 @BaseC2 _.base; 16 16 VMatrix _.V; 17 VMatrix _.Vi; 17 18 18 19 //////////////////////////////////////////////////////////////////////////// 19 20 Static Text _.autodoc.member.New = "Creates an instance B2 of " 20 21 "@BaseC2.LinComb as B2 = B1*V"; 21 Static @BaseC2.LinComb New(@BaseC2 B1, VMatrix V )22 Static @BaseC2.LinComb New(@BaseC2 B1, VMatrix V, VMatrix Vi) 22 23 //////////////////////////////////////////////////////////////////////////// 23 24 { … … 28 29 Real _.K = VColumns(V); 29 30 @BaseC2 _.base = base; 30 VMatrix _.V = V 31 VMatrix _.V = V; 32 VMatrix _.Vi = Vi 31 33 ]]}; 32 34 33 35 //////////////////////////////////////////////////////////////////////////// 34 Static Text _.autodoc.member.Compact = "Creates an instance of "36 Static Text _.autodoc.member.Compact.Ratio = "Creates an instance of " 35 37 "@BaseC2.LinComb that is close to be orthonormal and has at least " 36 38 "the specified ratio of information of original base"; 37 Static @BaseC2.LinComb Compact (39 Static @BaseC2.LinComb Compact.Ratio( 38 40 @BaseC2 base, 39 41 Real informationRatio) … … 51 53 Set Pu.svd = SVD(VMat2Mat(Pu)); 52 54 53 Matrix Pu.eigenvalue = RPow(Tra(SubDiag(Pu.svd[2],0)),1);55 Matrix Pu.eigenvalue = Tra(SubDiag(Pu.svd[2],0)); 54 56 Matrix Pu.eigenvalueCum = 55 57 { … … 58 60 }; 59 61 Matrix ratio = Rand(K1,1,informationRatio,informationRatio); 60 Real K.new = MatSum(LE(Pu.eigenvalueCum,ratio)); 61 VMatrix V = Mat2VMat(SubCol(Pu.svd[3],Range(1,K.new,1))); 62 New(base, V) 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 range.K = Range(1,K,1); 82 Real K1 = base::_.K; 83 84 VMatrix u = Rand(K1*10, K1, -1, 1); 85 86 VMatrix Pu = Group("ConcatColumns", For(1, K1, VMatrix(Real k) 87 { 88 base::function.v(k,u) 89 })); 90 91 Set Pu.svd = SVD(VMat2Mat(Pu)); 92 93 Matrix Pu.eigenvalue = Tra(SubDiag(Pu.svd[2],0)); 94 VMatrix V = Mat2VMat(SubCol(Pu.svd[3],range.K)); 95 VMatrix D = Eye(K,K,0,RPow(Mat2VMat(SubRow(Pu.eigenvalue,range.K)),+1)); 96 VMatrix Di = Eye(K,K,0,RPow(Mat2VMat(SubRow(Pu.eigenvalue,range.K)),-1)); 97 VMatrix W = V*Di; 98 VMatrix Wi = D*Tra(V); 99 New(base, W, Wi) 63 100 }; 64 101
Note: See TracChangeset
for help on using the changeset viewer.
