| 1 | /* -*- mode: C++ -*- */ |
|---|
| 2 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 3 | // FILE : BaseC2.tol |
|---|
| 4 | // PURPOSE: Defines Class @BaseC2 |
|---|
| 5 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 6 | |
|---|
| 7 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 8 | Text _.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."; |
|---|
| 18 | Class @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 | //Evaluates the partial integration of k-th basic function for an |
|---|
| 52 | //array of points given as the rows of a matrix |
|---|
| 53 | VMatrix _build.partial.integrate.1.v(Real k, VMatrix X, Real i) |
|---|
| 54 | { |
|---|
| 55 | //WriteLn("TRACE @BaseC2::_build.partial.derivative.1.v"); |
|---|
| 56 | SubCol( _build.partial.integrate.1.m(X,i),[[k]]) |
|---|
| 57 | }; |
|---|
| 58 | |
|---|
| 59 | //Evaluates all basic functions, one in each returned column, for an |
|---|
| 60 | //array of points given as the rows of a matrix |
|---|
| 61 | VMatrix _build.function.m(VMatrix X) |
|---|
| 62 | { |
|---|
| 63 | //WriteLn("TRACE @BaseC2::_build.function.m"); |
|---|
| 64 | Group("ConcatColumns", For(1,_.K,VMatrix(Real k) |
|---|
| 65 | { |
|---|
| 66 | _build.function.v(k, X) |
|---|
| 67 | })) |
|---|
| 68 | }; |
|---|
| 69 | //Evaluates the first partial derivative of all basic functions, one in |
|---|
| 70 | //each returned column, for an array of points given as the rows of a |
|---|
| 71 | //matrix |
|---|
| 72 | VMatrix _build.partial.derivative.1.m(VMatrix X, Real i) |
|---|
| 73 | { |
|---|
| 74 | //WriteLn("TRACE @BaseC2::_build.partial.derivative.1.m"); |
|---|
| 75 | Group("ConcatColumns", For(1,_.K,VMatrix(Real k) |
|---|
| 76 | { |
|---|
| 77 | _build.partial.derivative.1.v(k, X, i) |
|---|
| 78 | })) |
|---|
| 79 | }; |
|---|
| 80 | //Evaluates the second partial derivative of all basic functions, one in |
|---|
| 81 | //each returned column, for an array of points given as the rows of a |
|---|
| 82 | //matrix |
|---|
| 83 | VMatrix _build.partial.derivative.2.m(VMatrix X, Real i, Real j) |
|---|
| 84 | { |
|---|
| 85 | //WriteLn("TRACE @BaseC2::_build.partial.derivative.2.m"); |
|---|
| 86 | Group("ConcatColumns", For(1,_.K,VMatrix(Real k) |
|---|
| 87 | { |
|---|
| 88 | _build.partial.derivative.2.v(k, X, i, j) |
|---|
| 89 | })) |
|---|
| 90 | }; |
|---|
| 91 | //Evaluates the first partial integration of all basic functions, one in |
|---|
| 92 | //each returned column, for an array of points given as the rows of a |
|---|
| 93 | //matrix |
|---|
| 94 | VMatrix _build.partial.integrate.1.m(VMatrix X, Real i) |
|---|
| 95 | { |
|---|
| 96 | //WriteLn("TRACE @BaseC2::_build.partial.derivative.1.m"); |
|---|
| 97 | Group("ConcatColumns", For(1,_.K,VMatrix(Real k) |
|---|
| 98 | { |
|---|
| 99 | _build.partial.integrate.1.v(k, X, i) |
|---|
| 100 | })) |
|---|
| 101 | }; |
|---|
| 102 | //Some bases are more efficient using cache |
|---|
| 103 | Real _build.cache(VMatrix X, Real order) { False }; |
|---|
| 104 | |
|---|
| 105 | //////////////////////////////////////////////////////////////////////////// |
|---|
| 106 | //Public access methods call by defect to private ones |
|---|
| 107 | //////////////////////////////////////////////////////////////////////////// |
|---|
| 108 | |
|---|
| 109 | //Evaluates the k-th basic function for an |
|---|
| 110 | //array of points given as the rows of a matrix |
|---|
| 111 | VMatrix function.v(Real k, VMatrix X) |
|---|
| 112 | { |
|---|
| 113 | //WriteLn("TRACE @BaseC2::function.v"); |
|---|
| 114 | _build.function.v(k, X) |
|---|
| 115 | }; |
|---|
| 116 | //Evaluates the first partial derivative of k-th basic function for an |
|---|
| 117 | //array of points given as the rows of a matrix |
|---|
| 118 | VMatrix partial.derivative.1.v(Real k, VMatrix X, Real i) |
|---|
| 119 | { |
|---|
| 120 | //WriteLn("TRACE @BaseC2::partial.derivative.1.v"); |
|---|
| 121 | _build.partial.derivative.1.v(k, X, i) |
|---|
| 122 | }; |
|---|
| 123 | //Evaluates the second partial derivative of k-th basic function for an |
|---|
| 124 | //array of points given as the rows of a matrix |
|---|
| 125 | VMatrix partial.derivative.2.v(Real k, VMatrix X, Real i, Real j) |
|---|
| 126 | { |
|---|
| 127 | //WriteLn("TRACE @BaseC2::partial.derivative.2.v"); |
|---|
| 128 | _build.partial.derivative.2.v(k, X, i, j) |
|---|
| 129 | }; |
|---|
| 130 | //Evaluates the first partial integration of k-th basic function for an |
|---|
| 131 | //array of points given as the rows of a matrix |
|---|
| 132 | VMatrix partial.integrate.1.v(Real k, VMatrix X, Real i) |
|---|
| 133 | { |
|---|
| 134 | //WriteLn("TRACE @BaseC2::partial.derivative.1.v"); |
|---|
| 135 | _build.partial.integrate.1.v(k, X, i) |
|---|
| 136 | }; |
|---|
| 137 | |
|---|
| 138 | //Evaluates all basic functions, one in each returned column, for an |
|---|
| 139 | //array of points given as the rows of a matrix |
|---|
| 140 | VMatrix function.m(VMatrix X) |
|---|
| 141 | { |
|---|
| 142 | //WriteLn("TRACE @BaseC2::function.m"); |
|---|
| 143 | _build.function.m(X) |
|---|
| 144 | }; |
|---|
| 145 | //Evaluates the first partial derivative of all basic functions, one in |
|---|
| 146 | //each returned column, for an array of points given as the rows of a |
|---|
| 147 | //matrix |
|---|
| 148 | VMatrix partial.derivative.1.m(VMatrix X, Real i) |
|---|
| 149 | { |
|---|
| 150 | //WriteLn("TRACE @BaseC2::partial.derivative.1.m"); |
|---|
| 151 | _build.partial.derivative.1.m(X, i) |
|---|
| 152 | }; |
|---|
| 153 | //Evaluates the second partial derivative of all basic functions, one in |
|---|
| 154 | //each returned column, for an array of points given as the rows of a |
|---|
| 155 | //matrix |
|---|
| 156 | VMatrix partial.derivative.2.m(VMatrix X, Real i, Real j) |
|---|
| 157 | { |
|---|
| 158 | //WriteLn("TRACE @BaseC2::partial.derivative.2.m"); |
|---|
| 159 | _build.partial.derivative.2.m(X, i, j) |
|---|
| 160 | }; |
|---|
| 161 | |
|---|
| 162 | //Evaluates the first partial integration of all basic functions, one in |
|---|
| 163 | //each returned column, for an array of points given as the rows of a |
|---|
| 164 | //matrix |
|---|
| 165 | VMatrix partial.integrate.1.m(VMatrix X, Real i) |
|---|
| 166 | { |
|---|
| 167 | //WriteLn("TRACE @BaseC2::partial.derivative.1.m"); |
|---|
| 168 | _build.partial.integrate.1.m(X, i) |
|---|
| 169 | }; |
|---|
| 170 | //Some bases are more efficient using cache |
|---|
| 171 | Real upgrade.cache(VMatrix X, Real order) |
|---|
| 172 | { _build.cache(X,order) } |
|---|
| 173 | }; |
|---|