source: tol/tol_pkg/MulVarFunAprox/DesignC2.Monomial.Spheric.Grid.tol @ 38052b37

1941-docker-image-to-testdevel
Last change on this file since 38052b37 was 38052b37, checked in by Víctor de Buen <vdebuen@…>, 17 years ago

Renombrado de clases

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

  • Property mode set to 100644
File size: 5.2 KB
Line 
1/* -*- mode: C++ -*- */
2//////////////////////////////////////////////////////////////////////////////
3// FILE   : DesignC2.tol
4// PURPOSE: Defines Class @DesignC2
5//////////////////////////////////////////////////////////////////////////////
6
7
8//////////////////////////////////////////////////////////////////////////////
9Text _.autodoc.member.DesignC2.Monomial.Spheric.Grid =
10"";
11Class @DesignC2.Monomial.Spheric.Grid :
12  @DesignC2.Monomial,
13  @DesignC2.Spheric
14//////////////////////////////////////////////////////////////////////////////
15{
16//////////////////////////////////////////////////////////////////////////////
17//Configuration parameters
18//////////////////////////////////////////////////////////////////////////////
19  @IndexedGrid.Border _.grid;
20
21//////////////////////////////////////////////////////////////////////////////
22//Auxiliar members
23//////////////////////////////////////////////////////////////////////////////
24
25  ////////////////////////////////////////////////////////////////////////////
26  Static @DesignC2.Monomial.Spheric.Grid New(
27    VMatrix X,
28    Real radius.margin,
29    Real radius,
30    Real do.build.border)
31  ////////////////////////////////////////////////////////////////////////////
32  {
33    @DesignC2.Monomial.Spheric.Grid new =
34    [[
35      VMatrix _.X = X;
36      Real    _.n = VColumns(X);
37      Real    _.J = VRows(X);
38      Real    _.radius = radius;
39      Real    _.radius.margin = radius.margin;
40      Real    _.grid.size = radius/(1+radius.margin);
41      @IndexedGrid.Border _.grid = @IndexedGrid.Border::New(
42         X,_.grid.size,True,do.build.border,do.build.border)
43    ]]
44  };
45
46  //////////////////////////////////////////////////////////////////////////////
47  VMatrix closest.reference.index(VMatrix X)
48  //////////////////////////////////////////////////////////////////////////////
49  {
50    WriteLn("TRACE [closest.reference.index] 1");
51    SubRow(_.Y.neighbourhood, Col2Set(_.grid::point2index(X)))
52  };
53
54  //////////////////////////////////////////////////////////////////////////////
55  Real build.reference.points(Real void)
56  //////////////////////////////////////////////////////////////////////////////
57  {
58    Text _MID = "[@DesignC2.Monomial.Spheric.Grid::Grid.reference.points] ";
59    VMatrix _.Y := _.grid::_.Y;
60    VMatrix _.Y.h := Mat2VMat(_.grid::_.Y.h);
61    VMatrix _.Y.neighbourhood := _.Y.h | Group("ConcatColumns",
62    For(1,2*_.n, VMatrix(Real i)
63    {
64      VMatrix aux = SubCol(_.grid::_.Y.neighbourhood.index,[[i]]);
65      IfVMat(aux,aux,_.Y.h)
66    }));
67    Set X.class = Classify(Col2Set(_.grid::point2index(_.X)),Compare);
68    VMatrix _.Yj := Mat2VMat(SetMat([[EvalSet(X.class,Card)]]),1);
69    Real _.H := _.grid::_.H
70  };
71
72  //////////////////////////////////////////////////////////////////////////////
73  Real build.border.points(Real void)
74  //////////////////////////////////////////////////////////////////////////////
75  {
76    If(!Rows(_.grid::_.border.assign),{
77      VMatrix _.Yb := Zeros(_.H,1);
78      Real _.Tb := 0
79    },{
80    Text _MID = "[@DesignC2.Monomial.Spheric.Grid::build.border.points] ";
81    VMatrix   B.t  = Mat2VMat(SubCol(_.grid::_.border.assign,[[1]]));
82    VMatrix _.B.h := Mat2VMat(SubCol(_.grid::_.border.assign,[[2]]));
83    VMatrix _.B := SubRow(_.grid::_.border::_.Y, VCol2Set(B.t));
84    VMatrix aux = MatQuery::SortAndCount(_.B.h);
85    VMatrix _.Yb := Triplet(VMat2Mat(SubCol(aux,[[1]])) | 
86                            Rand(VRows(aux),1,1,1) |
87                            VMat2Mat(SubCol(aux,[[2]])),_.H,1);
88
89    Real _.Tb := VRows(_.B);
90    Real _.Mb := Case(
91      prior.B.order< 0, 0,
92      prior.B.order==0, _.Tb,
93      prior.B.order==1, _.Tb*(1+_.n),
94      prior.B.order==2, _.Tb*(1+_.n*3/2+(1/2)*_.n^2));
95    _.Tb
96    })
97  };
98
99  //////////////////////////////////////////////////////////////////////////////
100    Real build.model.design(Real void)
101  //////////////////////////////////////////////////////////////////////////////
102  {
103    Text _MID = "[@DesignC2.Monomial.Spheric.Grid::build.model.design] ";
104    FunRn2R::@BaseC2 base.max =
105      FunRn2R::@BaseC2.Monomial::New(_.n,max.deg);
106    Set Append(_.base, [[base.max]]);
107    Real _.base.sel := Card(_.base);
108    Real _.K0 := base.max::_.K;
109    _build.model.design(void)
110  };
111
112  ///////////////////////////////////////////////////////////////////////////
113    VMatrix generate.internal.points(
114      Real m,
115      Real force.reference.near.nodal)
116  ///////////////////////////////////////////////////////////////////////////
117  {
118    VMatrix h = Round(Rand(m,1,0.5,_.H+0.499999999));
119    VMatrix y = SubRow(_.Y,VCol2Set(h));
120    VMatrix v = Gaussian(m,_.n,0,1);
121    VMatrix u = v*(VMatDat(MtMSqr(v),1,1)^-0.5);
122    y+u*(Rand(0,1)*_.radius)
123  };
124
125  ////////////////////////////////////////////////////////////////////////////
126    VMatrix match.evaluable(VMatrix X)
127  ////////////////////////////////////////////////////////////////////////////
128  {
129    Real m = VRows(X);
130    Mat2VMat(_.grid::point2index(X))
131/*
132    VMatrix X.closest.index = closest.reference.index(X);
133    VMatrix X.h=SubRow(SubCol(_.Y.neighbourhood,[[1]]),
134                       VCol2Set(X.closest.index));
135    VMatrix X.dif = X - SubRow(_.Y,VCol2Set(X.h));
136    VMatrix X.norm2 = RPow(X.dif,2)*Rand(_.n,1,1,1);
137    VMatrix X.tao = RPow(X.norm2,0.5)/_.radius;
138    LE(X.tao,Rand(m,1,1,1))
139*/
140  }
141
142};
Note: See TracBrowser for help on using the repository browser.