SpectralElement.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 COMPONENTS_SPECTRALELEMENT_H
00030 #define COMPONENTS_SPECTRALELEMENT_H
00031
00032 #include <casa/aips.h>
00033 #include <casa/Arrays/Vector.h>
00034 #include <casa/Containers/RecordInterface.h>
00035
00036 namespace casa {
00037
00038 template <class T, class U> class Function;
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 class SpectralElement {
00079 public:
00080
00081
00082
00083 enum Types {
00084
00085 GAUSSIAN,
00086
00087 POLYNOMIAL,
00088
00089 COMPILED,
00090
00091 GMULTIPLET,
00092
00093 LORENTZIAN,
00094
00095 POWERLOGPOLY,
00096
00097 LOGTRANSPOLY,
00098 N_Types
00099 };
00100
00101 virtual ~SpectralElement();
00102
00103 virtual SpectralElement* clone() const = 0;
00104
00105
00106 virtual Double operator()(const Double x) const;
00107
00108 Bool operator==(const SpectralElement& other) const;
00109
00110
00111
00112
00113
00114 virtual Double operator[](const uInt n) const;
00115
00116
00117 static const String* allTypes(Int &nall,
00118 const SpectralElement::Types *&typ);
00119
00120 static const String &fromType(SpectralElement::Types tp);
00121
00122 static Bool toType(SpectralElement::Types &tp,
00123 const String &typName);
00124
00125
00126 SpectralElement::Types getType() const { return _type; }
00127
00128
00129 void get(Vector<Double>& params) const;
00130
00131 Vector<Double> get() const;
00132
00133
00134 void getError(Vector<Double> &err) const;
00135 Vector<Double> getError() const;
00136
00137
00138 uInt getOrder() const { return _params.size(); };
00139
00140
00141 virtual void setError(const Vector<Double> &err);
00142
00143
00144
00145
00146
00147
00148
00149 virtual void fix(const Vector<Bool>& fix);
00150
00151
00152 const Vector<Bool> &fixed() const;
00153
00154
00155 virtual Bool toRecord(RecordInterface& out) const;
00156
00157
00158 virtual void set(const Vector<Double>& params);
00159
00160 protected:
00161
00162 SpectralElement() {}
00163
00164 SpectralElement(Types type, const Vector<Double>& parms=Vector<Double>(0));
00165
00166 SpectralElement(const SpectralElement& other);
00167
00168 SpectralElement &operator=(const SpectralElement& other);
00169
00170 void _set(const Vector<Double>& params);
00171
00172 void _setType(const Types type);
00173
00174 void _setFunction(const SHARED_PTR<Function<Double, Double> >& f);
00175
00176 virtual SHARED_PTR<Function<Double, Double> > _getFunction() const {
00177 return _function;
00178 }
00179
00180 private:
00181
00182
00183 Types _type;
00184
00185
00186
00187 Vector<Double> _params;
00188
00189 Vector<Double> _errors;
00190
00191
00192 Vector<Bool> _fixed;
00193
00194 SHARED_PTR<Function<Double, Double> > _function;
00195
00196 };
00197
00198 ostream &operator<<(ostream& os, const SpectralElement& elem);
00199
00200 Bool near(const SpectralElement& s1, const SpectralElement& s2, const Double tol);
00201
00202 Bool nearAbs(const SpectralElement& s1, const SpectralElement& s2, const Double tol);
00203
00204
00205 }
00206
00207 #endif
00208