CMS 3D CMS Logo

rz_poly.h
Go to the documentation of this file.
1 #ifndef rz_poly_h
2 #define rz_poly_h
3 
10 #include <vector>
11 
12 namespace magfieldparam {
13 
14  //_______________________________________________________________________________
15  struct poly_term {
16  double coeff;
17  int np[2];
18  };
19 
20  //_______________________________________________________________________________
21  typedef std::vector<poly_term> poly_vect;
22  //_______________________________________________________________________________
23  typedef std::vector<poly_vect> poly_arr;
24 
25  //_______________________________________________________________________________
26  class rz_poly { // represent a set of homogeneous polynomials
27 
28  private:
29  poly_arr data;
30  int max_nr, max_nz, n_active;
31  double *r_pow;
32  double *z_pow;
33  bool *is_off;
34 
35  public:
36  rz_poly() : data(), max_nr(0), max_nz(0), n_active(0), r_pow(nullptr), z_pow(nullptr), is_off(nullptr){};
37 
38  rz_poly(int N);
39  rz_poly(const rz_poly &S);
40  ~rz_poly();
41 
42  void SetOFF(int npoly);
43  void SetON(int npoly);
44  void SetAllON(int npoly) {
45  if (is_off)
46  std::fill(is_off, is_off + data.size(), false);
47  }
48 
49  rz_poly Diff(int nvar, bool keep_empty = false);
50  rz_poly Int(int nvar);
51 
52  rz_poly &operator*=(double C);
53  rz_poly &operator*=(double *C);
54 
55  double GetSVal(double r, double z, const double *C) const;
56  double *GetVVal(double r, double z, double *rez_out = nullptr);
57 
58  int GetMaxRPow() const { return max_nr - 1; }
59  int GetMaxZPow() const { return max_nz - 1; }
60  int GetLength() const { return (int)data.size(); }
61  int GetNActive() const { return n_active; }
62 
63  double *Expand(double *C);
64 
65  void Print();
66  };
67 } // namespace magfieldparam
68 
69 #endif
Basic3DVector & operator*=(T t)
Scaling by a scalar value (multiplication)
std::vector< poly_term > poly_vect
Definition: rz_poly.h:21
int GetNActive() const
Definition: rz_poly.h:61
#define nullptr
void SetAllON(int npoly)
Definition: rz_poly.h:44
std::vector< poly_vect > poly_arr
Definition: rz_poly.h:23
int Int
Definition: forwards.h:16
int GetMaxZPow() const
Definition: rz_poly.h:59
#define N
Definition: blowfish.cc:9
int GetMaxRPow() const
Definition: rz_poly.h:58
int GetLength() const
Definition: rz_poly.h:60