source: tol/tol_pkg/FunRn2R/BaseC2.tol @ 4cbe84c

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

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

  • Property mode set to 100644
File size: 5.4 KB
Line 
1/* -*- mode: C++ -*- */
2//////////////////////////////////////////////////////////////////////////////
3// FILE   : BaseC2.tol
4// PURPOSE: Defines Class @BaseC2
5//////////////////////////////////////////////////////////////////////////////
6
7//////////////////////////////////////////////////////////////////////////////
8Text _.autodoc.member.BaseC2 =
9"Base of K mutivariate arbitrary linearly independent functions R^n -> R of "
10"class C2, ie, continuous and having first and second partial derivatives "
11"that are also continuous. For efficience reasons the base evaluates over "
12"massive arrays of points stored as rows in a matrix.\n"
13"Although all methods have a default definition this is an abstract class "
14"due to there are mutual interdependence between pairs of private methods "
15"_build.*.v and _build.*.m. At least a group of these methods must be "
16"redefined by inherited classes. Also is possible to redefine public "
17"access methods in order to not use private ones.";
18Class @BaseC2
19//////////////////////////////////////////////////////////////////////////////
20{
21  //Dimension of domain vectorial space
22  Real _.n;
23  //Dimension of the base
24  Real _.K;
25
26  ////////////////////////////////////////////////////////////////////////////
27  //Private calculation methods.
28  ////////////////////////////////////////////////////////////////////////////
29
30  //Evaluates the k-th basic function for an
31  //array of points given as the rows of a matrix
32  VMatrix _build.function.v(Real k, VMatrix X)
33  {
34  //WriteLn("TRACE @BaseC2::_build.function.v");
35    SubCol( _build.function.m(X),[[k]])
36  };
37  //Evaluates the first partial derivative of k-th basic function for an 
38  //array of points given as the rows of a matrix
39  VMatrix _build.partial.derivative.1.v(Real k, VMatrix X, Real i)
40  {
41  //WriteLn("TRACE @BaseC2::_build.partial.derivative.1.v");
42    SubCol( _build.partial.derivative.1.m(X,i),[[k]])
43  };
44  //Evaluates the second partial derivative of k-th basic function for an 
45  //array of points given as the rows of a matrix
46  VMatrix _build.partial.derivative.2.v(Real k, VMatrix X, Real i, Real j)
47  {
48  //WriteLn("TRACE @BaseC2::_build.partial.derivative.2.v");
49    SubCol( _build.partial.derivative.2.m(X,i,j),[[k]])
50  };
51
52  //Evaluates all basic functions, one in each returned column, for an
53  //array of points given as the rows of a matrix
54  VMatrix _build.function.m(VMatrix X)
55  {
56  //WriteLn("TRACE @BaseC2::_build.function.m");
57    Group("ConcatColumns", For(1,_.K,VMatrix(Real k)
58    {
59      _build.function.v(k, X)
60    }))
61  };
62  //Evaluates the first partial derivative of all basic functions, one in
63  //each returned column, for an  array of points given as the rows of a
64  //matrix
65  VMatrix _build.partial.derivative.1.m(VMatrix X, Real i)
66  {
67  //WriteLn("TRACE @BaseC2::_build.partial.derivative.1.m");
68    Group("ConcatColumns", For(1,_.K,VMatrix(Real k)
69    {
70      _build.partial.derivative.1.v(k, X, i)
71    }))
72  };
73  //Evaluates the second partial derivative of all basic functions, one in
74  //each returned column, for an  array of points given as the rows of a
75  //matrix
76  VMatrix _build.partial.derivative.2.m(VMatrix X, Real i, Real j)
77  {
78  //WriteLn("TRACE @BaseC2::_build.partial.derivative.2.m");
79    Group("ConcatColumns", For(1,_.K,VMatrix(Real k)
80    {
81      _build.partial.derivative.2.v(k, X, i, j)
82    }))
83  };
84  //Some bases are more efficient using cache
85  Real _build.cache(VMatrix X, Real order) { False };
86
87  ////////////////////////////////////////////////////////////////////////////
88  //Public access methods call by defect to private ones
89  ////////////////////////////////////////////////////////////////////////////
90
91  //Evaluates the k-th basic function for an
92  //array of points given as the rows of a matrix
93  VMatrix function.v(Real k, VMatrix X)
94  {
95  //WriteLn("TRACE @BaseC2::function.v");
96    _build.function.v(k, X)
97  };
98  //Evaluates the first partial derivative of k-th basic function for an 
99  //array of points given as the rows of a matrix
100  VMatrix partial.derivative.1.v(Real k, VMatrix X, Real i)
101  {
102  //WriteLn("TRACE @BaseC2::partial.derivative.1.v");
103    _build.partial.derivative.1.v(k, X, i)
104  };
105  //Evaluates the second partial derivative of k-th basic function for an 
106  //array of points given as the rows of a matrix
107  VMatrix partial.derivative.2.v(Real k, VMatrix X, Real i, Real j)
108  {
109  //WriteLn("TRACE @BaseC2::partial.derivative.2.v");
110    _build.partial.derivative.2.v(k, X, i, j)
111  };
112
113  //Evaluates all basic functions, one in each returned column, for an
114  //array of points given as the rows of a matrix
115  VMatrix function.m(VMatrix X)
116  {
117  //WriteLn("TRACE @BaseC2::function.m");
118    _build.function.m(X)
119  };
120  //Evaluates the first partial derivative of all basic functions, one in
121  //each returned column, for an  array of points given as the rows of a
122  //matrix
123  VMatrix partial.derivative.1.m(VMatrix X, Real i)
124  {
125  //WriteLn("TRACE @BaseC2::partial.derivative.1.m");
126    _build.partial.derivative.1.m(X, i)
127  };
128  //Evaluates the second partial derivative of all basic functions, one in
129  //each returned column, for an  array of points given as the rows of a
130  //matrix
131  VMatrix partial.derivative.2.m(VMatrix X, Real i, Real j)
132  {
133  //WriteLn("TRACE @BaseC2::partial.derivative.2.m");
134    _build.partial.derivative.2.m(X, i, j)
135  };
136
137  //Some bases are more efficient using cache
138  Real upgrade.cache(VMatrix X, Real order)
139  { _build.cache(X,order) }
140
141
142};
143
Note: See TracBrowser for help on using the repository browser.