Changeset 0c0e3bc in tol


Ignore:
Timestamp:
May 11, 2010, 4:31:09 PM (16 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
ad7e8ca
Parents:
8d33ed4f
Message:

explaining eqConstrainedStdGaussian
refs #902

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@2154 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol_pkg/BysVecLinReg/tools.tol

    r8d33ed4f r0c0e3bc  
    4747//
    4848// 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 columns
    50 // 2. Select p.2 as dependent components of x as first r pivoted columns
     49// 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
    5151// 4. Draw e.1 as standard independent normal
    5252// 5. Rewrite constraining linear equalities conditioned to e.1
    … …  
    5555//      e' = (e.1' e.2')
    5656//      C.1 * e.1 + C.2 * e.2 = c
    57 //      c.2 = c - C.1
     57//      c.2 = c - C.1*e.1
    5858//      C.2 * e.2 = c.2
    5959//
    6060// 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
    6263//    wanted draw of e
    6364//
    … …  
    6768  Real r = VRows(C);
    6869  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'
    7073  Matrix p = ColumnPivots(VMat2Mat(C2));
     74  //Select p.1 as gaussian components of x as (n-r) last pivoted columns
    7175  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
    7277  Set p.2 = MatSet(Sub(p,1,1,  1,r  ))[1];
    73 
     78  //Draw e.1 as standard independent normal
    7479  VMatrix e.1 = Gaussian(n-r,1,0,1);
     80  //Rewrite constraining linear equalities conditioned to e.1
    7581  VMatrix C.1 = SubCol(C,p.1);
    7682  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
    7985  VMatrix e.2 = MinimumResidualsSolve(C.2,c.2);
     86  //Checking method success
    8087  VMatrix err = C.2*e.2-c.2;
    8188  Real errMax = VMatMax(Abs(err));
    82   If((n^3)+errMax^2 != n^3,
     89  If((n*r^2)+errMax^2 != n*r^2,
    8390    WriteLn("[BysVecLinReg::eqConstrainedStdGaussian] errMax="<<errMax,"W"));
     91  //Merging gaussian and dependent components following the selected
     92  //pivoting order
    8493  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))
    8694};
Note: See TracChangeset for help on using the changeset viewer.