File indexing completed on 2023-03-17 11:14:37
0001 #ifndef rz_poly_h
0002 #define rz_poly_h
0003
0004
0005
0006
0007
0008
0009
0010 #include <vector>
0011
0012 namespace magfieldparam {
0013
0014
0015 struct poly_term {
0016 double coeff;
0017 int np[2];
0018 };
0019
0020
0021 typedef std::vector<poly_term> poly_vect;
0022
0023 typedef std::vector<poly_vect> poly_arr;
0024
0025
0026 class rz_poly {
0027
0028 private:
0029 poly_arr data;
0030 int max_nr, max_nz, n_active;
0031 double *r_pow;
0032 double *z_pow;
0033 bool *is_off;
0034
0035 public:
0036 rz_poly() : data(), max_nr(0), max_nz(0), n_active(0), r_pow(nullptr), z_pow(nullptr), is_off(nullptr){};
0037
0038 rz_poly(int N);
0039 rz_poly(const rz_poly &S);
0040 ~rz_poly();
0041
0042 void SetOFF(int npoly);
0043 void SetON(int npoly);
0044 void SetAllON(int npoly) {
0045 if (is_off)
0046 std::fill(is_off, is_off + data.size(), false);
0047 }
0048
0049 rz_poly Diff(int nvar, bool keep_empty = false);
0050 rz_poly Int(int nvar);
0051
0052 rz_poly &operator*=(double C);
0053 rz_poly &operator*=(double *C);
0054
0055 double GetSVal(double r, double z, const double *C) const;
0056 double *GetVVal(double r, double z, double *rez_out = nullptr);
0057
0058 int GetMaxRPow() const { return max_nr - 1; }
0059 int GetMaxZPow() const { return max_nz - 1; }
0060 int GetLength() const { return (int)data.size(); }
0061 int GetNActive() const { return n_active; }
0062
0063 double *Expand(double *C);
0064
0065 void Print();
0066 };
0067 }
0068
0069 #endif