Ignore:
Timestamp:
Dec 2, 2009, 5:20:39 PM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
f79532b
Parents:
17d3fef
Message:

New member VMatrix _.Vi for inverse change of variable
New method Static @BaseC2.LinComb Compact.K

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol_pkg/FunRn2R/BaseC2.LinComb.tol

    r17d3fef r280293c  
    1515  @BaseC2 _.base;
    1616  VMatrix _.V;
     17  VMatrix _.Vi;
    1718
    1819  ////////////////////////////////////////////////////////////////////////////
    1920  Static Text _.autodoc.member.New = "Creates an instance B2 of "
    2021  "@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)
    2223  ////////////////////////////////////////////////////////////////////////////
    2324  {
    … …  
    2829      Real _.K = VColumns(V);
    2930      @BaseC2 _.base = base;
    30       VMatrix _.V = V
     31      VMatrix _.V = V;
     32      VMatrix _.Vi = Vi
    3133  ]]};
    3234
    3335  ////////////////////////////////////////////////////////////////////////////
    34   Static Text _.autodoc.member.Compact = "Creates an instance of "
     36  Static Text _.autodoc.member.Compact.Ratio = "Creates an instance of "
    3537  "@BaseC2.LinComb that is close to be orthonormal and has at least "
    3638  "the specified ratio of information of original base";
    37   Static @BaseC2.LinComb Compact(
     39  Static @BaseC2.LinComb Compact.Ratio(
    3840    @BaseC2 base,
    3941    Real informationRatio)
    … …  
    5153    Set Pu.svd = SVD(VMat2Mat(Pu));
    5254
    53     Matrix Pu.eigenvalue = RPow(Tra(SubDiag(Pu.svd[2],0)),1);
     55    Matrix Pu.eigenvalue = Tra(SubDiag(Pu.svd[2],0));
    5456    Matrix Pu.eigenvalueCum =
    5557    {
    … …  
    5860    };
    5961    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)
    63100  };
    64101
Note: See TracChangeset for help on using the changeset viewer.