Ignore:
Timestamp:
Dec 23, 2009, 12:22:50 PM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
68d1346
Parents:
29ef418
Message:

El número de parámetros puede ser distinto en cada punto de referencia

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol_pkg/MulVarFunAprox/DesignC2.tol

    r29ef418 rfa86b43  
    2121//////////////////////////////////////////////////////////////////////////////
    2222  Real prior.Z.order = 2;
    23   Real prior.B.order = 0;
     23  Real prior.B.order = 1;
    2424  Real min.contrast.surface = 3;
    2525
    … …  
    9494    Real _.M := _.J+_.Mb+_.Mz;
    9595    Real build.base(0);
    96     Real _.N := _.H*_.K;
     96    Real _.N := VMatSum(_.Yn);
    9797    _.N<_.M
    9898  };
    … …  
    116116    If(!m, Rand(0,_.N,0,0), {
    117117    WriteLn("TRACE "+_MID+"2");
     118    VMatrix X.j=DifEq(1/(1-B),Rand(m,1,1,1));
    118119    WriteLn("TRACE "+_MID+"3");
    119     VMatrix X.j=DifEq(1/(1-B),Rand(m,1,1,1));
    120     WriteLn("TRACE "+_MID+"4");
    121120    Set X.dif = For(1,_.X.maxNeighbour,VMatrix(Real i)
    122121    {
    … …  
    124123      X - SubRow(_.Y,X.h.i)
    125124    });
     125    WriteLn("TRACE "+_MID+"4");
     126    Set X.weight = get.X.weight(X.dif);
    126127    WriteLn("TRACE "+_MID+"5");
    127     Set X.weight = get.X.weight(X.dif);
    128     WriteLn("TRACE "+_MID+"6");
     128    VMatrix YnCum = DifEq(1/(1-B),_.Yn);
     129    VMatrix YnCumB = Sub(SetCol([[0]])<<YnCum,1,1,_.H,1);
    129130    Matrix QX.triplet = Group("ConcatRows", For(1,_.X.maxNeighbour,Matrix(Real i)
    130131    {
    … …  
    132133      Set sel.rows = MatQuery::SelectMatch(NE(Drop(Abs(w.i),1.E-15),w.i*0));
    133134      VMatrix wi = SubRow(w.i,sel.rows);
    134       VMatrix X.hiK = SubRow((SubCol(X.h,[[i]])-1)*_.K,sel.rows);
     135      VMatrix X.hi = SubCol(X.h,[[i]]);
     136      Set X.hi.set = VCol2Set(X.hi);
     137      VMatrix X.hiK0 = SubRow(SubRow(YnCumB,X.hi.set),sel.rows);
     138      VMatrix X.hiK1 = SubRow(SubRow(YnCum, X.hi.set),sel.rows);
    135139      VMatrix Xdif.i = SubRow(X.dif[i],sel.rows);
    136140      VMatrix X.j.i = SubRow(X.j,sel.rows);
    … …  
    140144        VMatrix pk = eval::evaluate.v(k,Xdif.i);
    141145        VMatrix qk = wi$*pk;
    142         VMat2Mat(X.j.i | (X.hiK+k) | qk)
     146        VMatrix X.hik = X.hiK0+k;
     147        VMatrix match = LE(X.hik,X.hiK1);
     148        SubRow(VMat2Mat(X.j.i | (X.hik) | qk),MatQuery::SelectMatch(match))
    143149      }))
    144150    }));
    145     WriteLn("TRACE "+_MID+"7");
     151    WriteLn("TRACE "+_MID+"6");
    146152    Pack(Convert(Triplet(QX.triplet, m, _.N),"Cholmod.R.Sparse"))
    147153  })};
    … …  
    172178    Set X.weight.der = get.X.weight.partial.derivative.1(X.dif,s);
    173179    WriteLn("TRACE "+_MID+"6");
     180    VMatrix YnCum = DifEq(1/(1-B),_.Yn);
     181    VMatrix YnCumB = Sub(SetCol([[0]])<<YnCum,1,1,_.H,1);
    174182    Matrix QX.triplet = Group("ConcatRows", For(1,_.X.maxNeighbour,Matrix(Real i)
    175183    {
    … …  
    178186      VMatrix wi = SubRow(w.i,sel.rows);
    179187      VMatrix wi.der = SubRow(X.weight.der[i],sel.rows);
    180       VMatrix X.hiK = SubRow((SubCol(X.h,[[i]])-1)*_.K,sel.rows);
     188      VMatrix X.hi = SubCol(X.h,[[i]]);
     189      Set X.hi.set = VCol2Set(X.hi);
     190      VMatrix X.hiK0 = SubRow(SubRow(YnCumB,X.hi.set),sel.rows);
     191      VMatrix X.hiK1 = SubRow(SubRow(YnCum, X.hi.set),sel.rows);
    181192      VMatrix Xdif.i = SubRow(X.dif[i],sel.rows);
    182193      VMatrix X.j.i = SubRow(X.j,sel.rows);
    … …  
    188199        VMatrix pk.der = der::evaluate.v(k,Xdif.i);
    189200        VMatrix qk = wi$*pk.der+wi.der$*pk;
    190         VMat2Mat(X.j.i | (X.hiK+k) | qk)
     201        VMatrix X.hik = X.hiK0+k;
     202        VMatrix match = LE(X.hik,X.hiK1);
     203        SubRow(VMat2Mat(X.j.i | (X.hik) | qk),MatQuery::SelectMatch(match))
    191204      }))
    192205    }));
    … …  
    204217    VMatrix B.dif = _.B - Y;
    205218    FunRn2R::@BaseC2 b = get.base(0);   
     219    VMatrix YnCum = DifEq(1/(1-B),_.Yn);
     220    VMatrix YnCumB = Sub(SetCol([[0]])<<YnCum,1,1,_.H,1);
    206221    Matrix PB.triplet =
    207222    {
    208       VMatrix B.hK = (_.B.h-1)*_.K;
     223    //VMatrix B.hK = (_.B.h-1)*_.K;
     224      Set B.h.set = VCol2Set(_.B.h);
     225      VMatrix B.hK0 = SubRow(YnCumB,B.h.set);
     226      VMatrix B.hK1 = SubRow(YnCum, B.h.set);
     227
    209228      Real b::upgrade.cache(B.dif,prior.B.order,0);
    210229      Real lastRow = 0;
    … …  
    213232        Real cumRows = lastRow;
    214233        VMatrix pk = b::function.v(k,B.dif);
    215         VMatrix col.idx = (B.hK+k);
     234        VMatrix B.hk = B.hK0+k;
     235        VMatrix match = LE(B.hk,B.hK1);
     236        Set selRows = MatQuery::SelectMatch(match);
    216237        {
    217238          VMatrix row.idx = B.t+cumRows;
    218239          Real cumRows := cumRows + _.Tb;
    219           VMat2Mat(row.idx | col.idx | pk)
     240          SubRow(VMat2Mat(row.idx | B.hk | pk),selRows)
    220241        }  << If(prior.B.order<1,Rand(0,3,0,0),
    221242        Group("ConcatRows",For(1,_.n,Matrix(Real d)
    … …  
    224245          VMatrix row.idx = B.t+cumRows;
    225246          Real cumRows := cumRows + _.Tb;
    226           VMat2Mat(row.idx | col.idx | pkd)
     247          SubRow(VMat2Mat(row.idx | B.hk | pkd),selRows)
    227248        })))<< If(prior.B.order<2,Rand(0,3,0,0),
    228249        Group("ConcatRows",For(1,_.n,Matrix(Real d1)
    … …  
    233254            VMatrix row.idx = B.t+cumRows;
    234255            Real cumRows := cumRows + _.Tb;
    235             VMat2Mat(row.idx | col.idx | pkd2)
     256            SubRow(VMat2Mat(row.idx | B.hk | pkd2),selRows)
    236257          }))
    237258        })))
    … …  
    252273    });
    253274    FunRn2R::@BaseC2 b = get.base(0);   
     275    VMatrix YnCum = DifEq(1/(1-B),_.Yn);
     276    VMatrix YnCumB = Sub(SetCol([[0]])<<YnCum,1,1,_.H,1);
    254277    Matrix PZ.triplet = Group("ConcatRows", For(1,_.Z.maxNeighbour,Matrix(Real i)
    255278    {
    256       VMatrix Z.hiK = (SubCol(_.Z.h,[[i]])-1)*_.K;
     279      VMatrix Z.hi = SubCol(_.Z.h,[[i]]);
     280      Set Z.hi.set = VCol2Set(Z.hi);
     281      VMatrix Z.hiK0 = SubRow(YnCumB,Z.hi.set);
     282      VMatrix Z.hiK1 = SubRow(YnCum, Z.hi.set);
     283
    257284      VMatrix Zdif.i = Z.dif[i];
    258285      VMatrix Z.t.i = Z.t;
    … …  
    263290        Real cumRows = lastRow;
    264291        VMatrix pk = b::function.v(k,Zdif.i)*If(i==1,+1,-1);
    265         VMatrix col.idx = (Z.hiK+k);
     292        VMatrix Z.hik = Z.hiK0+k;
     293        VMatrix match = LE(Z.hik,Z.hiK1);
     294        Set selRows = MatQuery::SelectMatch(match);
    266295        {
    267296          VMatrix row.idx = Z.t.i+cumRows;
    268297          Real cumRows := cumRows + _.Tz;
    269           VMat2Mat(row.idx | col.idx | pk)
     298          SubRow(VMat2Mat(row.idx | Z.hik | pk),selRows)
    270299        }  << If(prior.Z.order<1,Rand(0,3,0,0),
    271300        Group("ConcatRows",For(1,_.n,Matrix(Real d)
    … …  
    275304          VMatrix row.idx = Z.t.i+cumRows;
    276305          Real cumRows := cumRows + _.Tz;
    277           VMat2Mat(row.idx | col.idx | pkd)
     306          SubRow(VMat2Mat(row.idx | Z.hik | pkd),selRows)
    278307        })))<< If(prior.Z.order<2,Rand(0,3,0,0),
    279308        Group("ConcatRows",For(1,_.n,Matrix(Real d1)
    … …  
    285314            VMatrix row.idx = Z.t.i+cumRows;
    286315            Real cumRows := cumRows + _.Tz;
    287             VMat2Mat(row.idx | col.idx | pkd2)
     316            SubRow(VMat2Mat(row.idx | Z.hik | pkd2),selRows)
    288317          }))
    289318        })))
    … …  
    307336    VMatrix _.Q := _.QX << _.QB << _.PZ;
    308337    WriteLn("TRACE "+_MID+"5");
     338/*
    309339    VMatrix _.Q.nonNullCellsByColumns :=
    310340    {
    … …  
    315345      }))
    316346    };
     347*/
    317348    WriteLn("TRACE "+_MID+"6");
    318349    VMatrix _.LQ := CholeskiFactor(_.Q,"XtX");
Note: See TracChangeset for help on using the changeset viewer.