Changeset 0c0e3bc in tol
- Timestamp:
- May 11, 2010, 4:31:09 PM (16 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- ad7e8ca
- Parents:
- 8d33ed4f
- File:
-
- 1 edited
-
tol_pkg/BysVecLinReg/tools.tol (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol_pkg/BysVecLinReg/tools.tol
r8d33ed4f r0c0e3bc 47 47 // 48 48 // 1. Get pivoting order p of columns of diagonal of C*C' 49 // 3. Select p.1 as gaussian components of x as (n-r) last pivoted columns50 // 2. Select p.2 as dependent components of x as first r pivoted columns49 // 2. Select p.1 as gaussian components of x as (n-r) last pivoted columns 50 // 3. Select p.2 as dependent components of x as first r pivoted columns 51 51 // 4. Draw e.1 as standard independent normal 52 52 // 5. Rewrite constraining linear equalities conditioned to e.1 … … 55 55 // e' = (e.1' e.2') 56 56 // C.1 * e.1 + C.2 * e.2 = c 57 // c.2 = c - C.1 57 // c.2 = c - C.1*e.1 58 58 // C.2 * e.2 = c.2 59 59 // 60 60 // 6. Solve linear system to get e.2 61 // 7. Merge e.1 and e.2 following the selected pivoting order to get the 61 // 7. Checks if solution has the expected rounding error 62 // 8. Merge e.1 and e.2 following the selected pivoting order to get the 62 63 // wanted draw of e 63 64 // … … 67 68 Real r = VRows(C); 68 69 Real n = VColumns(C); 69 VMatrix C2 = Constant(1,r,1) * (C$*C); 70 //Calculates diagonal of C*C' in a faster way 71 VMatrix C2 = Constant(1,r,1) * (C $* C); 72 //Builds pivoting order of columns of diagonal of C*C' 70 73 Matrix p = ColumnPivots(VMat2Mat(C2)); 74 //Select p.1 as gaussian components of x as (n-r) last pivoted columns 71 75 Set p.1 = MatSet(Sub(p,1,r+1,1,n-r))[1]; 76 //Select p.2 as dependent components of x as first r pivoted columns 72 77 Set p.2 = MatSet(Sub(p,1,1, 1,r ))[1]; 73 78 //Draw e.1 as standard independent normal 74 79 VMatrix e.1 = Gaussian(n-r,1,0,1); 80 //Rewrite constraining linear equalities conditioned to e.1 75 81 VMatrix C.1 = SubCol(C,p.1); 76 82 VMatrix C.2 = SubCol(C,p.2); 77 VMatrix c. 1 =C.1 * e.1;78 VMatrix c.2 = c-c.1;83 VMatrix c.2 = c-C.1 * e.1; 84 //Solve linear system to get e.2 79 85 VMatrix e.2 = MinimumResidualsSolve(C.2,c.2); 86 //Checking method success 80 87 VMatrix err = C.2*e.2-c.2; 81 88 Real errMax = VMatMax(Abs(err)); 82 If((n ^3)+errMax^2 != n^3,89 If((n*r^2)+errMax^2 != n*r^2, 83 90 WriteLn("[BysVecLinReg::eqConstrainedStdGaussian] errMax="<<errMax,"W")); 91 //Merging gaussian and dependent components following the selected 92 //pivoting order 84 93 Triplet(SetCol(p.1<<p.2) | Constant(n,1,1) | VMat2Mat(e.1 << e.2), n, 1) 85 //SetOfMatrix(Tra(p), Constant(n,1,1),VMat2Mat(e.1 << e.2))86 94 };
Note: See TracChangeset
for help on using the changeset viewer.
