Changeset 3f198cc in tol


Ignore:
Timestamp:
Dec 23, 2009, 2:25:56 PM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
f389530
Parents:
38052b37
Message:

Preparando para permitir radio variante en los entornos esféricos

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

Location:
tol_pkg/MulVarFunAprox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • tol_pkg/MulVarFunAprox/DesignC2.Monomial.Spheric.Grid.tol

    r38052b37 r3f198cc  
    1414//////////////////////////////////////////////////////////////////////////////
    1515{
     16  @IndexedGrid.Border _.grid;
    1617//////////////////////////////////////////////////////////////////////////////
    1718//Configuration parameters
    1819//////////////////////////////////////////////////////////////////////////////
    19   @IndexedGrid.Border _.grid;
     20  Real _.radius;
     21  Real _.radius.margin;
     22  Real _.grid.size;
    2023
    2124//////////////////////////////////////////////////////////////////////////////
    2225//Auxiliar members
    2326//////////////////////////////////////////////////////////////////////////////
     27  VMatrix _.Y.h = Rand(0,0,0,0);
     28  VMatrix _.Y.neighbourhood = Rand(0,0,0,0);
    2429
    2530  ////////////////////////////////////////////////////////////////////////////
    … …  
    4550
    4651  //////////////////////////////////////////////////////////////////////////////
     52  VMatrix get.radius(VMatrix Y.idx)
     53  //////////////////////////////////////////////////////////////////////////////
     54  {
     55    Constant(VRows(Y.idx),1,_.radius)
     56  };
     57
     58  //////////////////////////////////////////////////////////////////////////////
    4759  VMatrix closest.reference.index(VMatrix X)
    4860  //////////////////////////////////////////////////////////////////////////////
    … …  
    6880    VMatrix _.Yj := Mat2VMat(SetMat([[EvalSet(X.class,Card)]]),1);
    6981    Real _.H := _.grid::_.H
     82  };
     83
     84  //////////////////////////////////////////////////////////////////////////////
     85  Real build.stress.points(Real void)
     86  //////////////////////////////////////////////////////////////////////////////
     87  {
     88    Text _MID = "[@DesignC2.Spheric::build.stress.points] ";
     89    WriteLn("TRACE "+_MID+"1");
     90    Matrix Y.neighbour.triplet = Group("ConcatRows", For(1,_.H,Matrix(Real h)
     91    {
     92      Set neighbours = Unique(VRow2Set(SubRow(_.Y.neighbourhood,[[h]])));
     93      Set neighbours.up = Select(neighbours,Real(Real s) { s>h });
     94      Matrix s = SetCol(Sort(neighbours.up,Compare));
     95      Rand(Rows(s),1,h,h)|s|Rand(Rows(s),1,1,1)
     96    }));
     97
     98    WriteLn("TRACE "+_MID+"2");
     99    VMatrix Y.neighbour.1.map = Triplet(Y.neighbour.triplet,_.H,_.H);
     100    VMatrix Y.neighbour.2.map = Y.neighbour.1.map*Y.neighbour.1.map;
     101    VMatrix Y.neighbour.12.map = Max(Y.neighbour.1.map,Y.neighbour.2.map);
     102    Matrix Y.neighbour.12.triplet = VMat2Triplet(Y.neighbour.12.map);
     103    VMatrix Z.h.a = Mat2VMat(SubCol(Y.neighbour.12.triplet,[[1]]));
     104    VMatrix Z.h.b = Mat2VMat(SubCol(Y.neighbour.12.triplet,[[2]]));
     105    VMatrix Y.neighbour.a = SubRow(_.Y,VCol2Set(Z.h.a));
     106    VMatrix Y.neighbour.b = SubRow(_.Y,VCol2Set(Z.h.b));
     107    VMatrix Z.all = (Y.neighbour.a + Y.neighbour.b)*0.5;
     108
     109    WriteLn("TRACE "+_MID+"3");
     110    VMatrix Z.interior.a =
     111    {
     112      VMatrix Z.norm2 = RPow(Y.neighbour.a-Z.all,2)*Rand(_.n,1,1,1);
     113      VMatrix Z.tao = RPow(Z.norm2,0.5)/_.radius;
     114      LE(Z.tao,Rand(VRows(Z.tao),1,1,1))
     115    };
     116    VMatrix Z.interior.b =
     117    {
     118      VMatrix Z.norm2 = RPow(Y.neighbour.b-Z.all,2)*Rand(_.n,1,1,1);
     119      VMatrix Z.tao = RPow(Z.norm2,0.5)/_.radius;
     120      LE(Z.tao,Rand(VRows(Z.tao),1,1,1))
     121    };
     122    VMatrix match.interior = Z.interior.a $* Z.interior.b;
     123
     124    Set sel.interior = MatQuery::SelectMatch(match.interior);
     125    VMatrix Z.interior = SubRow(Z.all,sel.interior);
     126    VMatrix Z.h.interior = SubRow(Z.h.a | Z.h.b,sel.interior);
     127    Set criterium = Range(1,_.n,1);
     128    Set sel.unique = Col2Set(Sort(VMat2Mat(Z.interior),criterium,True));
     129    WriteLn("TRACE "+_MID+"4");
     130    VMatrix _.Z := SubRow(Z.interior, sel.unique);
     131    VMatrix _.Z.h := SubRow(Z.h.interior, sel.unique);
     132    Real _.Tz := VRows(_.Z);
     133    VMatrix _.Z.Y.neighbour :=
     134    {
     135      Matrix Z.t = DifEq(1/(1-B),Rand(_.Tz,1,1,1));
     136      Matrix Z.th = (Z.t << Z.t) |
     137       VMat2Mat((SubCol(_.Z.h,[[1]])<<SubCol(_.Z.h,[[2]])));
     138      Matrix Z.Y.idx = PivotByRows(Z.th,Sort(Z.th,[[2]]));
     139      VMatrix Z.Y.dif =
     140       SubRow(_.Z,Col2Set(SubCol(Z.Y.idx,[[1]]))) -
     141       SubRow(_.Y,Col2Set(SubCol(Z.Y.idx,[[2]])));
     142        VMatrix Z.Y.norm2 = RPow(Z.Y.dif,2)*Rand(_.n,1,1,1);
     143        VMatrix Z.Y.tao = RPow(Z.Y.norm2,0.5)/_.radius;
     144        VMatrix Z.Y.match = LE(Z.Y.tao,Rand(VRows(Z.Y.tao),1,1,1));
     145      SubRow(Mat2VMat(Z.Y.idx),MatQuery::SelectMatch(Z.Y.match))
     146    };
     147    VMatrix aux = MatQuery::SortAndCount(SubCol(_.Z.Y.neighbour,[[2]]));
     148    VMatrix _.Yt := Triplet(VMat2Mat(SubCol(aux,[[1]])) | 
     149                            Rand(VRows(aux),1,1,1) |
     150                            VMat2Mat(SubCol(aux,[[2]])),_.H,1);
     151    Real _.Mz := Case(
     152      prior.Z.order< 0, 0,
     153      prior.Z.order==0, _.Tz,
     154      prior.Z.order==1, _.Tz*(1+_.n),
     155      prior.Z.order==2, _.Tz*(1+_.n*3/2+(1/2)*_.n^2));
     156    _.Tz
    70157  };
    71158
  • tol_pkg/MulVarFunAprox/DesignC2.Monomial.Spheric.MeshFree.tol

    r38052b37 r3f198cc  
    22//////////////////////////////////////////////////////////////////////////////
    33// FILE   : DesignC2.Monomial.Spheric.MeshFree.tol
    4 // PURPOSE: Defines Class @DesignC2.Monomial.Spheric.MeshFree.tol
     4// PURPOSE: Defines Class @DesignC2.Monomial.Spheric.MeshFree
    55//////////////////////////////////////////////////////////////////////////////
    66
    … …  
    99Text _.autodoc.member.DesignC2.Monomial.Spheric.MeshFree.tol =
    1010"";
    11 Class @DesignC2.Monomial.Spheric.MeshFree.tol :
     11Class @DesignC2.Monomial.Spheric.MeshFree :
    1212  @DesignC2.Monomial,
    1313  @DesignC2.Spheric
    … …  
    1717//Configuration parameters
    1818//////////////////////////////////////////////////////////////////////////////
    19   @IndexedGrid.Border _.grid;
     19  MatQuery::@ANN.KDTree _.ann;
    2020
    2121//////////////////////////////////////////////////////////////////////////////
    … …  
    2424
    2525  ////////////////////////////////////////////////////////////////////////////
    26   Static @DesignC2.Monomial.Spheric.MeshFree.tol New(
     26  Static @DesignC2.Monomial.Spheric.MeshFree New(
    2727    VMatrix X,
    2828    Real radius.margin,
    … …  
    3131  ////////////////////////////////////////////////////////////////////////////
    3232  {
    33     @DesignC2.Monomial.Spheric.MeshFree.tol new =
     33    @DesignC2.Monomial.Spheric.MeshFree new =
    3434    [[
    3535      VMatrix _.X = X;
    … …  
    7878      Real _.Tb := 0
    7979    },{
    80     Text _MID = "[@DesignC2.Monomial.Spheric.MeshFree.tol::build.border.points] ";
     80    Text _MID = "[@DesignC2.Monomial.Spheric.MeshFree::build.border.points] ";
    8181    VMatrix   B.t  = Mat2VMat(SubCol(_.grid::_.border.assign,[[1]]));
    8282    VMatrix _.B.h := Mat2VMat(SubCol(_.grid::_.border.assign,[[2]]));
    … …  
    101101  //////////////////////////////////////////////////////////////////////////////
    102102  {
    103     Text _MID = "[@DesignC2.Monomial.Spheric.MeshFree.tol::build.model.design] ";
     103    Text _MID = "[@DesignC2.Monomial.Spheric.MeshFree::build.model.design] ";
    104104    FunRn2R::@BaseC2 base.max =
    105105      FunRn2R::@BaseC2.Monomial::New(_.n,max.deg);
  • tol_pkg/MulVarFunAprox/DesignC2.Spheric.tol

    r38052b37 r3f198cc  
    1212//////////////////////////////////////////////////////////////////////////////
    1313{
    14 //////////////////////////////////////////////////////////////////////////////
    15 //Configuration parameters
    16 //////////////////////////////////////////////////////////////////////////////
    17   Real _.radius;
    18   Real _.radius.margin;
    19   Real _.grid.size;
    20 
    21 //////////////////////////////////////////////////////////////////////////////
    22 //Auxiliar members
    23 //////////////////////////////////////////////////////////////////////////////
    24   VMatrix _.Y.h = Rand(0,0,0,0);
    25   VMatrix _.Y.neighbourhood = Rand(0,0,0,0);
    26 
    2714  //////////////////////////////////////////////////////////////////////////////
    28   Real build.stress.points(Real void)
     15  //Virtual methods
    2916  //////////////////////////////////////////////////////////////////////////////
    30   {
    31     Text _MID = "[@DesignC2.Spheric::build.stress.points] ";
    32     WriteLn("TRACE "+_MID+"1");
    33     Matrix Y.neighbour.triplet = Group("ConcatRows", For(1,_.H,Matrix(Real h)
    34     {
    35       Set neighbours = Unique(VRow2Set(SubRow(_.Y.neighbourhood,[[h]])));
    36       Set neighbours.up = Select(neighbours,Real(Real s) { s>h });
    37       Matrix s = SetCol(Sort(neighbours.up,Compare));
    38       Rand(Rows(s),1,h,h)|s|Rand(Rows(s),1,1,1)
    39     }));
    40 
    41     WriteLn("TRACE "+_MID+"2");
    42     VMatrix Y.neighbour.1.map = Triplet(Y.neighbour.triplet,_.H,_.H);
    43     VMatrix Y.neighbour.2.map = Y.neighbour.1.map*Y.neighbour.1.map;
    44     VMatrix Y.neighbour.12.map = Max(Y.neighbour.1.map,Y.neighbour.2.map);
    45     Matrix Y.neighbour.12.triplet = VMat2Triplet(Y.neighbour.12.map);
    46     VMatrix Z.h.a = Mat2VMat(SubCol(Y.neighbour.12.triplet,[[1]]));
    47     VMatrix Z.h.b = Mat2VMat(SubCol(Y.neighbour.12.triplet,[[2]]));
    48     VMatrix Y.neighbour.a = SubRow(_.Y,VCol2Set(Z.h.a));
    49     VMatrix Y.neighbour.b = SubRow(_.Y,VCol2Set(Z.h.b));
    50     VMatrix Z.all = (Y.neighbour.a + Y.neighbour.b)*0.5;
    51 
    52     WriteLn("TRACE "+_MID+"3");
    53     VMatrix Z.interior.a =
    54     {
    55       VMatrix Z.norm2 = RPow(Y.neighbour.a-Z.all,2)*Rand(_.n,1,1,1);
    56       VMatrix Z.tao = RPow(Z.norm2,0.5)/_.radius;
    57       LE(Z.tao,Rand(VRows(Z.tao),1,1,1))
    58     };
    59     VMatrix Z.interior.b =
    60     {
    61       VMatrix Z.norm2 = RPow(Y.neighbour.b-Z.all,2)*Rand(_.n,1,1,1);
    62       VMatrix Z.tao = RPow(Z.norm2,0.5)/_.radius;
    63       LE(Z.tao,Rand(VRows(Z.tao),1,1,1))
    64     };
    65     VMatrix match.interior = Z.interior.a $* Z.interior.b;
    66 
    67     Set sel.interior = MatQuery::SelectMatch(match.interior);
    68     VMatrix Z.interior = SubRow(Z.all,sel.interior);
    69     VMatrix Z.h.interior = SubRow(Z.h.a | Z.h.b,sel.interior);
    70     Set criterium = Range(1,_.n,1);
    71     Set sel.unique = Col2Set(Sort(VMat2Mat(Z.interior),criterium,True));
    72     WriteLn("TRACE "+_MID+"4");
    73     VMatrix _.Z := SubRow(Z.interior, sel.unique);
    74     VMatrix _.Z.h := SubRow(Z.h.interior, sel.unique);
    75     Real _.Tz := VRows(_.Z);
    76     VMatrix _.Z.Y.neighbour :=
    77     {
    78       Matrix Z.t = DifEq(1/(1-B),Rand(_.Tz,1,1,1));
    79       Matrix Z.th = (Z.t << Z.t) |
    80        VMat2Mat((SubCol(_.Z.h,[[1]])<<SubCol(_.Z.h,[[2]])));
    81       Matrix Z.Y.idx = PivotByRows(Z.th,Sort(Z.th,[[2]]));
    82       VMatrix Z.Y.dif =
    83        SubRow(_.Z,Col2Set(SubCol(Z.Y.idx,[[1]]))) -
    84        SubRow(_.Y,Col2Set(SubCol(Z.Y.idx,[[2]])));
    85         VMatrix Z.Y.norm2 = RPow(Z.Y.dif,2)*Rand(_.n,1,1,1);
    86         VMatrix Z.Y.tao = RPow(Z.Y.norm2,0.5)/_.radius;
    87         VMatrix Z.Y.match = LE(Z.Y.tao,Rand(VRows(Z.Y.tao),1,1,1));
    88       SubRow(Mat2VMat(Z.Y.idx),MatQuery::SelectMatch(Z.Y.match))
    89     };
    90     VMatrix aux = MatQuery::SortAndCount(SubCol(_.Z.Y.neighbour,[[2]]));
    91     VMatrix _.Yt := Triplet(VMat2Mat(SubCol(aux,[[1]])) | 
    92                             Rand(VRows(aux),1,1,1) |
    93                             VMat2Mat(SubCol(aux,[[2]])),_.H,1);
    94     Real _.Mz := Case(
    95       prior.Z.order< 0, 0,
    96       prior.Z.order==0, _.Tz,
    97       prior.Z.order==1, _.Tz*(1+_.n),
    98       prior.Z.order==2, _.Tz*(1+_.n*3/2+(1/2)*_.n^2));
    99     _.Tz
    100   };
     17  VMatrix get.radius(VMatrix Y.idx);
    10118
    10219  ///////////////////////////////////////////////////////////////////////////
    103   Set get.X.weight(Set X.dif)
     20  Set get.X.weight(Set X.dif, Set X.h)
    10421  ///////////////////////////////////////////////////////////////////////////
    10522  {
    … …  
    10825    {
    10926      VMatrix X.norm2 = RPow(X.dif[i],2)*Rand(_.n,1,1,1);
    110       RPow(X.norm2,0.5)/_.radius
     27      RPow(X.norm2,0.5)$/get.radius(X.h[i])
    11128    });
    11229    Set X.tao2 = For(1,_.X.maxNeighbour,VMatrix(Real i)
    … …  
    13047  };
    13148  ///////////////////////////////////////////////////////////////////////////
    132   Set get.X.weight.partial.derivative.1(Set X.dif, Real s)
     49  Set get.X.weight.partial.derivative.1(Set X.dif, Set X.h, Real s)
    13350  ///////////////////////////////////////////////////////////////////////////
    13451  {
    … …  
    13754    {
    13855      VMatrix X.norm2 = RPow(X.dif[i],2)*Rand(_.n,1,1,1);
    139       RPow(X.norm2,0.5)/_.radius
     56      RPow(X.norm2,0.5)$/get.radius(X.h[i])
    14057    });
    14158    Set X.tao2 = For(1,_.X.maxNeighbour,VMatrix(Real i)
    … …  
    15370    Set X.lambda.der = For(1,_.X.maxNeighbour,VMatrix(Real i)
    15471    {
    155       RPow(X.match[i] $* (Rand(m,1,1,1)-X.tao2[i]),3)$*SubCol(X.dif[i],[[s]])*8/_.radius
     72      RPow(X.match[i] $*
     73           (Rand(m,1,1,1)-X.tao2[i]),3) $*
     74           (SubCol(X.dif[i],[[s]])*8) $/ get.radius(X.h[i])
    15675    });
    15776    VMatrix X.lambda.sum = SetSum(X.lambda);
  • tol_pkg/MulVarFunAprox/DesignC2.tol

    r38052b37 r3f198cc  
    7575  VMatrix closest.reference.index(VMatrix X);
    7676  VMatrix match.evaluable(VMatrix X);
    77   Set get.X.weight(Set X.dif);
    78   Set get.X.weight.partial.derivative.1(Set X.dif, Real s);
     77  Set get.X.weight(Set X.dif, Set X.h);
     78  Set get.X.weight.partial.derivative.1(Set X.dif, Set X.h, Real s);
    7979
    8080  //////////////////////////////////////////////////////////////////////////////
    … …  
    118118    VMatrix X.j=DifEq(1/(1-B),Rand(m,1,1,1));
    119119    WriteLn("TRACE "+_MID+"3");
     120    Set X.h_ = For(1,_.X.maxNeighbour,VMatrix(Real i) { SubCol(X.h,[[i]]) });
    120121    Set X.dif = For(1,_.X.maxNeighbour,VMatrix(Real i)
    121122    {
    122       Set X.h.i = VCol2Set(SubCol(X.h,[[i]]));
     123      Set X.h.i = VCol2Set(X.h_[i]);
    123124      X - SubRow(_.Y,X.h.i)
    124125    });
    125126    WriteLn("TRACE "+_MID+"4");
    126     Set X.weight = get.X.weight(X.dif);
     127    Set X.weight = get.X.weight(X.dif, X.h_);
    127128    WriteLn("TRACE "+_MID+"5");
    128129    VMatrix YnCum = DifEq(1/(1-B),_.Yn);
    … …  
    169170    VMatrix X.j=DifEq(1/(1-B),Rand(m,1,1,1));
    170171    WriteLn("TRACE "+_MID+"4");
     172    Set X.h_ = For(1,_.X.maxNeighbour,VMatrix(Real i) { SubCol(X.h,[[i]]) });
    171173    Set X.dif = For(1,_.X.maxNeighbour,VMatrix(Real i)
    172174    {
    173       Set X.h.i = VCol2Set(SubCol(X.h,[[i]]));
     175      Set X.h.i = VCol2Set(X.h_[i]);
    174176      X - SubRow(_.Y,X.h.i)
    175177    });
    176178    WriteLn("TRACE "+_MID+"5");
    177     Set X.weight = get.X.weight(X.dif);
    178     Set X.weight.der = get.X.weight.partial.derivative.1(X.dif,s);
     179    Set X.weight = get.X.weight(X.dif, X.h_);
     180    Set X.weight.der = get.X.weight.partial.derivative.1(X.dif,X.h_,s);
    179181    WriteLn("TRACE "+_MID+"6");
    180182    VMatrix YnCum = DifEq(1/(1-B),_.Yn);
Note: See TracChangeset for help on using the changeset viewer.