00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef MOMENTS_H
00021 #define MOMENTS_H
00022
00023 #include <vector>
00024 #include "cmindices.h"
00025 #include "elementintegrator.h"
00026 #include "specfun.h"
00027 #include <assert.h>
00028
00029 typedef std::vector<double> convcoeffs;
00030
00035 class moments{
00036 std::vector<double> S;
00037 std::vector<double> V;
00038 public:
00046 moments(const cmindices &cmi, const dcmplx c, int nelem, const elementintegrator& integrator);
00047
00048
00053 moments(const cmindices &cmi);
00054
00059 inline const std::vector<double> & getS() const {return S;};
00060
00065 inline const std::vector<double> & getV() const {return V;};
00066
00073 inline moments& chargeMul(double qF, double qV, double qS) {
00074 for(int i=0;i<S.size();i++) {
00075 double v=V[i];
00076 V[i]=qV*V[i]+qS*S[i];
00077 S[i]=qF*v;
00078
00079
00080 };
00081 };
00082
00086 inline void erase() {
00087 for(int i=0;i<S.size();i++) {
00088 S[i]=0.0;
00089 V[i]=0.0;
00090 };
00091
00092 };
00093
00100 void addShifted(const cmindices& cmi, const moments &m, dcmplx shift);
00101
00108 inline void addShifted(const cmindices& cmi, const moments &m, const convcoeffs &cm) {
00109 cmi.addUpConv(m.S, cm, S);
00110 cmi.addUpConv(m.V, cm, V);
00111 };
00118 void addShiftedTaylor(const cmindices& cmi, const moments &m, dcmplx shift);
00119
00126 inline void addShiftedTaylor(const cmindices& cmi, const moments &m, const convcoeffs &cm) {
00127 cmi.addDownConv(m.S, cm, S);
00128 cmi.addDownConv(m.V, cm, V);
00129 };
00130
00138 inline void addTaylor(const cmindices& cmi, const moments &m, const convcoeffs &dpS, const convcoeffs &dpV) {
00139 cmi.addDownConv(dpS,m.S,S);
00140 cmi.addDownConv(dpV,m.V,V);
00141 };
00142
00149 inline moments & operator+=(const moments &rhs) {
00150 assert((S.size()==V.size()) && (rhs.S.size()==rhs.V.size()) && (S.size()==rhs.S.size()));
00151 for(int i=0;i<S.size();i++) {
00152 S[i]+=rhs.S[i];
00153 V[i]+=rhs.V[i];
00154 };
00155 return *this;
00156 };
00157
00164 inline const moments operator+(const moments &other) const {
00165 moments result = *this;
00166 result += other;
00167 return result;
00168 };
00169
00175 inline double operator*(const moments &other) const {
00176 assert((S.size()==V.size()) && (other.S.size()==other.V.size()) && (S.size()==other.S.size()));
00177 double res=0.0;
00178 for(int i=0;i<S.size();i++) {
00179 res+=S[i]*other.S[i]+0.5*V[i]*other.V[i];
00180 };
00181 return res;
00182 };
00183
00188 virtual int getStorage();
00189
00190 ~moments();
00191
00192 };
00193
00194 #endif