CompoundParam.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef SCIMATH_COMPOUNDPARAM_H
00030 #define SCIMATH_COMPOUNDPARAM_H
00031
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/scimath/Functionals/Function.h>
00034 #include <casacore/casa/BasicSL/String.h>
00035 #include <casacore/casa/Containers/Block.h>
00036
00037 namespace casacore {
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 template<class T> class CompoundParam : public Function<T>
00102 {
00103 public:
00104
00105
00106
00107 CompoundParam();
00108
00109
00110 CompoundParam(const CompoundParam<T> &other);
00111 CompoundParam(const CompoundParam<T> &other, Bool) :
00112 Function<T>(other), ndim_p(other.ndim_p),
00113 functionPtr_p(other.functionPtr_p.nelements()),
00114 paroff_p(other.paroff_p.nelements()),
00115 funpar_p(other.funpar_p.nelements()),
00116 locpar_p(other.locpar_p.nelements()) {
00117 for (uInt i=0; i<functionPtr_p.nelements(); ++i) {
00118 functionPtr_p[i] = other.functionPtr_p[i]->clone();
00119 paroff_p[i] = other.paroff_p[i];
00120 }
00121 for (uInt i=0; i<funpar_p.nelements(); ++i) {
00122 funpar_p[i] = other.funpar_p[i];
00123 locpar_p[i] = other.locpar_p[i];
00124 }
00125 }
00126 template <class W>
00127 CompoundParam(const CompoundParam<W> &other) :
00128 Function<T>(other), ndim_p(other.ndim()),
00129 functionPtr_p(other.nFunctions()),
00130 paroff_p(other.nFunctions()),
00131 funpar_p(other.nparameters()),
00132 locpar_p(other.nparameters()) {
00133 for (uInt i=0; i<functionPtr_p.nelements(); ++i) {
00134 functionPtr_p[i] = other.function(i).cloneAD();
00135 paroff_p[i] = other.parameterOffset(i);
00136 }
00137 for (uInt i=0; i<funpar_p.nelements(); ++i) {
00138 funpar_p[i] = other.parameterFunction(i);
00139 locpar_p[i] = other.parameterLocation(i);
00140 }
00141 }
00142 template <class W>
00143 CompoundParam(const CompoundParam<W> &other, Bool) :
00144 Function<T>(other), ndim_p(other.ndim()),
00145 functionPtr_p(other.nFunctions()),
00146 paroff_p(other.nFunctions()),
00147 funpar_p(other.nparameters()),
00148 locpar_p(other.nparameters()) {
00149 for (uInt i=0; i<functionPtr_p.nelements(); ++i) {
00150 functionPtr_p[i] = other.function(i).cloneNonAD();
00151 paroff_p[i] = other.parameterOffset(i);
00152 }
00153 for (uInt i=0; i<funpar_p.nelements(); ++i) {
00154 funpar_p[i] = other.parameterFunction(i);
00155 locpar_p[i] = other.parameterLocation(i);
00156 }
00157 }
00158 CompoundParam<T> &operator=(const CompoundParam<T> &other);
00159
00160
00161 virtual ~CompoundParam();
00162
00163
00164
00165
00166
00167 virtual const String &name() const { static String x("compound");
00168 return x; }
00169
00170
00171
00172
00173 uInt addFunction(const Function<T> &newFunction);
00174
00175
00176 uInt nFunctions() const { return functionPtr_p.nelements(); }
00177
00178
00179
00180 const Function<T> &function(uInt which) const {
00181 DebugAssert(nFunctions() > which, AipsError);
00182 return *(functionPtr_p[which]); }
00183
00184
00185 uInt parameterOffset(uInt which) const {
00186 DebugAssert(nFunctions() > which, AipsError); return paroff_p[which]; }
00187
00188 uInt parameterFunction(uInt which) const {
00189 DebugAssert(nparameters() > which, AipsError);
00190 return funpar_p[which];
00191 }
00192
00193 uInt parameterLocation(uInt which) const {
00194 DebugAssert(nparameters() > which, AipsError);
00195 return locpar_p[which];
00196 }
00197
00198 virtual uInt ndim() const { return ndim_p; }
00199
00200 private:
00201
00202
00203 uInt ndim_p;
00204
00205 protected:
00206
00207
00208 PtrBlock<Function<T> *> functionPtr_p;
00209
00210 Block<uInt> paroff_p;
00211
00212 Block<uInt> funpar_p;
00213
00214 Block<uInt> locpar_p;
00215
00216
00217 protected:
00218 using Function<T>::parset_p;
00219 using Function<T>::param_p;
00220 public:
00221 using Function<T>::nparameters;
00222 };
00223
00224
00225 }
00226
00227 #ifndef CASACORE_NO_AUTO_TEMPLATES
00228 #include <casacore/scimath/Functionals/CompoundParam.tcc>
00229 #endif //# CASACORE_NO_AUTO_TEMPLATES
00230 #endif