Ignore:
Timestamp:
Dec 4, 2009, 4:44:16 PM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
4bd88af
Parents:
fabac4a
Message:

New class hierarchy

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol_pkg/MulVarFunAprox/DesignC2.tol

    rfabac4a rb050cc43  
    2828  Real _.X.maxNeighbour = ?;
    2929  Real _.Z.maxNeighbour = ?;
    30   VMatrix _.Y = Rand(0,0,0,0);
    31   Real _.H = ?;
    32   VMatrix _.Z = Rand(0,0,0,0);
    33   VMatrix _.Z.h = Rand(0,0,0,0);
    34   Real _.T = ?;
    35   Real _.Mz = ?;
    36   Real _.M = ?;
    37   Real _.K = ?;
    38   Real _.N = ?;
     30  VMatrix _.Y = Rand(0,2,0,0);
     31  VMatrix _.Z = Rand(0,2,0,0);
     32  VMatrix _.Z.h = Rand(0,1,0,0);
     33  VMatrix _.B = Rand(0,2,0,0);
     34  VMatrix _.B.h = Rand(0,0,0,0);
     35  Real _.K = 0;
     36  Real _.H = 0;
     37  Real _.Tz = 0;
     38  Real _.Mz = 0;
     39  Real _.Tb = 0;
     40  Real _.Mb = 0;
     41  Real _.M = 0;
     42  Real _.N = 0;
    3943  Set _.base = Copy(Empty);
    4044  Real _.base.sel = ?;
    4145  VMatrix _.QX = Rand(0,0,0,0);
     46  VMatrix _.QB = Rand(0,0,0,0);
    4247  VMatrix _.PZ = Rand(0,0,0,0);
    4348  VMatrix _.Q = Rand(0,0,0,0);
    4449  VMatrix _.LQ = Rand(0,0,0,0);
    45 
     50  VMatrix _.Q.nonNullCellsByColumns = Rand(0,0,0,0);
    4651  //////////////////////////////////////////////////////////////////////////////
    4752  NameBlock get.base(Real sel)
    … …  
    5560  //Virtual methods
    5661  //////////////////////////////////////////////////////////////////////////////
     62  Real build.base(Real void);
    5763  Real build.reference.points(Real void);
    58   Real build.stress.points(Real void);
    59   Real build.base(Real void);
     64  Real build.stress.points(Real void) { False };
     65  Real build.border.points(Real void) { False };
     66  VMatrix closest.reference.index(VMatrix X);
    6067  Set get.X.weight(Set X.dif);
    6168  VMatrix match.evaluable(VMatrix X);
    62   VMatrix closest.reference.index(VMatrix X);
    6369
    6470  //////////////////////////////////////////////////////////////////////////////
    … …  
    7076    Real build.reference.points(0);
    7177    Real build.stress.points(0);
    72     Real _.M := _.J+_.Mz;
     78    Real build.border.points(0);
     79    Real _.M := _.J+_.Mb+_.Mz;
    7380    Real build.base(0);
    7481    Real _.N := _.H*_.K;
    … …  
    8491
    8592  //////////////////////////////////////////////////////////////////////////////
    86     VMatrix build.obs(VMatrix X)
    87   //////////////////////////////////////////////////////////////////////////////
    88   {
     93    VMatrix build.obs(VMatrix X, VMatrix X.h)
     94  //////////////////////////////////////////////////////////////////////////////
     95  {
     96    Text _MID = "[@DesignC2::build.obs] ";
    8997    Real m = VRows(X);
    90     VMatrix X.h=closest.reference.index(X);
     98    WriteLn("TRACE "+_MID+"1 m="<<m);
     99    If(!m, Rand(0,_.N,0,0), {
     100    WriteLn("TRACE "+_MID+"2");
     101    WriteLn("TRACE "+_MID+"2");
    91102    VMatrix X.j=DifEq(1/(1-B),Rand(m,1,1,1));
     103    WriteLn("TRACE "+_MID+"2");
    92104    Set X.dif = For(1,_.X.maxNeighbour,VMatrix(Real i)
    93105    {
    … …  
    95107      X - SubRow(_.Y,X.h.i)
    96108    });
     109    WriteLn("TRACE "+_MID+"2");
    97110    Set X.weight = get.X.weight(X.dif);
     111    WriteLn("TRACE "+_MID+"2");
    98112    FunRn2R::@BaseC2 b = get.base(0);
     113    WriteLn("TRACE "+_MID+"2");
    99114    Matrix QX.triplet = Group("ConcatRows", For(1,_.X.maxNeighbour,Matrix(Real i)
    100115    {
    … …  
    114129    }));
    115130    Pack(Convert(Triplet(QX.triplet, m, _.N),"Cholmod.R.Sparse"))
    116   };
    117   //////////////////////////////////////////////////////////////////////////////
    118     VMatrix build.prior(Real void)
    119   //////////////////////////////////////////////////////////////////////////////
    120   {
    121     VMatrix Z.t=DifEq(1/(1-B),Rand(_.T,1,1,1));
     131  })};
     132  //////////////////////////////////////////////////////////////////////////////
     133    VMatrix build.border.prior(Real void)
     134  //////////////////////////////////////////////////////////////////////////////
     135  {
     136    If(!_.Tb, Rand(0,_.N,0,0), {
     137    VMatrix B.t=DifEq(1/(1-B),Rand(_.Tb,1,1,1));
     138    VMatrix Y = SubRow(_.Y, VCol2Set(_.B.h));
     139    VMatrix B.dif = _.B - Y;
     140    FunRn2R::@BaseC2 b = get.base(0);   
     141    Matrix PB.triplet =
     142    {
     143      VMatrix B.hK = (_.B.h-1)*_.K;
     144      Real b::upgrade.cache(B.dif,prior.Z.order);
     145      Real lastRow = 0;
     146      Group("ConcatRows", For(1,_.K,Matrix(Real k)
     147      {
     148        Real cumRows = lastRow;
     149        VMatrix pk = b::function.v(k,B.dif);
     150        VMatrix col.idx = (B.hK+k);
     151        {
     152          VMatrix row.idx = B.t+cumRows;
     153          Real cumRows := cumRows + _.Tb;
     154          VMat2Mat(row.idx | col.idx | pk)
     155        }  << If(prior.Z.order<1,Rand(0,3,0,0),
     156        Group("ConcatRows",For(1,_.n,Matrix(Real d)
     157        {
     158          VMatrix pkd = b::partial.derivative.1.v(k,B.dif,d);
     159          VMatrix row.idx = B.t+cumRows;
     160          Real cumRows := cumRows + _.Tb;
     161          VMat2Mat(row.idx | col.idx | pkd)
     162        })))<< If(prior.Z.order<2,Rand(0,3,0,0),
     163        Group("ConcatRows",For(1,_.n,Matrix(Real d1)
     164        {
     165          Group("ConcatRows",For(1,d1,Matrix(Real d2)
     166          {
     167            VMatrix pkd2 = b::partial.derivative.2.v(k,B.dif,d1,d2);
     168            VMatrix row.idx = B.t+cumRows;
     169            Real cumRows := cumRows + _.Tb;
     170            VMat2Mat(row.idx | col.idx | pkd2)
     171          }))
     172        })))
     173      }))
     174    };
     175    Convert(Triplet(PB.triplet, _.Mb, _.N),"Cholmod.R.Sparse")
     176  })};
     177  //////////////////////////////////////////////////////////////////////////////
     178    VMatrix build.stress.prior(Real void)
     179  //////////////////////////////////////////////////////////////////////////////
     180  {
     181    If(!_.Tz, Rand(0,_.N,0,0), {
     182    VMatrix Z.t=DifEq(1/(1-B),Rand(_.Tz,1,1,1));
    122183   
    123184    Set Z.dif = For(1,_.Z.maxNeighbour,VMatrix(Real i)
    … …  
    140201        {
    141202          VMatrix row.idx = Z.t.i+cumRows;
    142           Real cumRows := cumRows + _.T;
     203          Real cumRows := cumRows + _.Tz;
    143204          VMat2Mat(row.idx | col.idx | pk)
    144205        }  << If(prior.Z.order<1,Rand(0,3,0,0),
    … …  
    148209          VMatrix pkd = b::partial.derivative.1.v(k,Zdif.i,d)*sign;
    149210          VMatrix row.idx = Z.t.i+cumRows;
    150           Real cumRows := cumRows + _.T;
     211          Real cumRows := cumRows + _.Tz;
    151212          VMat2Mat(row.idx | col.idx | pkd)
    152213        })))<< If(prior.Z.order<2,Rand(0,3,0,0),
    … …  
    158219            VMatrix pkd2 = b::partial.derivative.2.v(k,Zdif.i,d1,d2)*sign;
    159220            VMatrix row.idx = Z.t.i+cumRows;
    160             Real cumRows := cumRows + _.T;
     221            Real cumRows := cumRows + _.Tz;
    161222            VMat2Mat(row.idx | col.idx | pkd2)
    162223          }))
    … …  
    165226    }));
    166227    Convert(Triplet(PZ.triplet, _.Mz, _.N),"Cholmod.R.Sparse")
    167   };
     228  })};
    168229  //////////////////////////////////////////////////////////////////////////////
    169230    Real build.decomposition(Real void)
    170231  //////////////////////////////////////////////////////////////////////////////
    171232  {
    172     VMatrix _.QX := build.obs(_.X);
    173     VMatrix _.PZ := build.prior(0);
    174     VMatrix Q.all = _.QX << _.PZ;
    175     Set Q.active = MatQuery::SelectMatch(
    176       NE(Tra(Rand(1,_.M,1,1)*Abs(Q.all)),Rand(_.N,1,0,0)));
    177     VMatrix _.Q := SubCol(Q.all,Q.active);
     233    Text _MID = "[@DesignC2::build.decomposition] ";
     234    WriteLn("TRACE "+_MID+"1");
     235    VMatrix X.h=closest.reference.index(_.X);
     236    VMatrix _.QX := build.obs(_.X, X.h);
     237    WriteLn("TRACE "+_MID+"2");
     238    VMatrix _.QB := build.border.prior(0);
     239    WriteLn("TRACE "+_MID+"3");
     240    VMatrix _.PZ := build.stress.prior(0);
     241    WriteLn("TRACE "+_MID+"4");
     242    VMatrix _.Q := _.QX << _.QB << _.PZ;
     243    WriteLn("TRACE "+_MID+"7");
     244    VMatrix _.Q.nonNullCellsByColumns :=
     245    {
     246      VMatrix aux = Tra(Rand(1,_.M,1,1)*Or(_.Q,Zeros(_.M,_.N)));
     247      Group("ConcatColumns",For(1,_.K,VMatrix(Real k)
     248      {
     249        SubRow(aux,Range(k,_.N,_.K))
     250      }))
     251    };
     252    WriteLn("TRACE "+_MID+"8");
    178253    VMatrix _.LQ := CholeskiFactor(_.Q,"XtX");
     254    WriteLn("TRACE "+_MID+"9");
    179255    True
    180256  }
Note: See TracChangeset for help on using the changeset viewer.