Go to the documentation of this file.00001 #ifndef rz_harm_poly_h
00002 #define rz_harm_poly_h
00003
00004 #include <cmath>
00005 #include "poly2d_base.h"
00006
00008
00009
00010
00012
00013
00014 namespace magfieldparam {
00015 struct trig_pair {
00016 double CosPhi;
00017 double SinPhi;
00018
00019 trig_pair() : CosPhi(1.), SinPhi(0.) {}
00020 trig_pair(const trig_pair &tp) : CosPhi(tp.CosPhi), SinPhi(tp.SinPhi) {}
00021 trig_pair(const double C, const double S) : CosPhi(C), SinPhi(S) {}
00022 trig_pair(const double phi) : CosPhi(cos(phi)), SinPhi(sin(phi)) {}
00023
00024
00025 trig_pair Add(const trig_pair &tp) {
00026 return trig_pair(this->CosPhi*tp.CosPhi - this->SinPhi*tp.SinPhi,
00027 this->SinPhi*tp.CosPhi + this->CosPhi*tp.SinPhi);
00028 }
00029 };
00030
00032
00033
00034
00036
00037
00038 class rz_harm_poly : public poly2d_base {
00039
00040 private:
00041 unsigned L;
00042 int M;
00043
00044 static unsigned Cnt;
00045 static double phival;
00046 static bool phi_set;
00047 static unsigned MaxM;
00048
00049 static unsigned TASize;
00050 static trig_pair *TrigArr;
00051
00052 static void SetTrigArrSize(const unsigned N);
00053 static void FillTrigArr (const double phi);
00054
00055 void PrintLM(std::ostream &out = std::cout)
00056 {
00057 out << "L=" << std::setw(3) << std::left << L
00058 <<", M=" << std::setw(3) << std::left << M << "; ";
00059 }
00060
00061 public:
00062
00063 static int GetMaxM();
00064 static unsigned ParentCount() { return poly2d_base::Count();}
00065 static unsigned Count() { return Cnt;}
00066 static void SetPhi(const double phi);
00067 static void SetPoint(const double r, const double z, const double phi)
00068 {
00069 poly2d_base::SetPoint(r, z); SetPhi(phi);
00070 }
00071
00072 rz_harm_poly() : poly2d_base(), L(0), M(0) {++Cnt;}
00073 rz_harm_poly(const poly2d_base &S) : poly2d_base(S), L(0), M(0) {++Cnt;}
00074 rz_harm_poly(const rz_harm_poly &S) : poly2d_base(S), L(S.L), M(S.M) {++Cnt;}
00075 rz_harm_poly(const unsigned N);
00076 ~rz_harm_poly();
00077
00078 bool IsPhiSet() { return phi_set;}
00079
00080 rz_harm_poly GetDiff (int nvar) { rz_harm_poly R(*this); R.Diff (nvar); return R;}
00081 rz_harm_poly GetInt (int nvar) { rz_harm_poly R(*this); R.Int (nvar); return R;}
00082 rz_harm_poly GetIncPow(int nvar) { rz_harm_poly R(*this); R.IncPow(nvar); return R;}
00083 rz_harm_poly GetDecPow(int nvar) { rz_harm_poly R(*this); R.DecPow(nvar); return R;}
00084
00085 rz_harm_poly LadderUp();
00086 rz_harm_poly LadderDwn();
00087
00088 unsigned GetL() { return L;}
00089 int GetM() { return M;}
00090
00091
00092
00093
00094 double GetCos() { return TrigArr[M].CosPhi;}
00095 double GetSin() { return TrigArr[M].SinPhi;}
00096
00097 void CheatL(const unsigned newL) { L = newL;}
00098 void Print(std::ostream &out = std::cout, const std::streamsize prec = 5)
00099 { PrintLM(out); poly2d_base::Print(out, prec);}
00100
00101
00102 static void PrintTrigArr(std::ostream &out = std::cout, const std::streamsize prec = 5);
00103
00104 };
00105 }
00106
00107 #endif