8 rz_poly::rz_poly(
int N) {
9 int nz,
nr = 0, nv,
nt;
22 for (
int m = 2;
m <=
N; ++
m) {
37 v3x[nv].coeff = -v3x[nv - 1].coeff * (nz + 1) * (nz + 2) / (
nr *
nr);
45 r_pow =
new double[max_nr];
46 z_pow =
new double[max_nz];
47 fill(r_pow, r_pow + max_nr, 1.);
48 fill(z_pow, z_pow + max_nz, 1.);
50 n_active =
data.size();
51 is_off =
new bool[n_active];
52 fill(is_off, is_off + n_active,
false);
60 n_active =
S.n_active;
63 r_pow =
new double[max_nr];
64 copy(
S.r_pow,
S.r_pow + max_nr, r_pow);
69 z_pow =
new double[max_nz];
70 copy(
S.z_pow,
S.z_pow + max_nz, z_pow);
75 is_off =
new bool[
data.size()];
76 copy(
S.is_off,
S.is_off +
data.size(), is_off);
92 void rz_poly::SetOFF(
int npoly) {
93 if ((npoly < 0) || (npoly >= (
int)
data.size()))
102 void rz_poly::SetON(
int npoly) {
103 if ((npoly < 0) || (npoly >= (
int)
data.size()))
106 is_off[npoly] =
false;
112 void rz_poly::Print() {
114 cout <<
"The \"rz_poly\" object is NOT initialized!" << endl;
118 for (
unsigned int ip = 0; ip <
data.size(); ++ip) {
119 cout <<
"Polynomial " << ip <<
" (size=" <<
data[ip].size() <<
", status=";
121 cout <<
"OFF):" << endl;
123 cout <<
"ON):" << endl;
124 for (
unsigned int it = 0; it <
data[ip].size(); ++it) {
125 cout <<
"\tnr=" <<
data[ip][it].np[0] <<
"\tnz=" <<
data[ip][it].np[1] <<
"\tcoeff=" <<
data[ip][it].coeff
132 rz_poly rz_poly::Diff(
int nvar,
bool keep_empty) {
142 bool *tmp_mask =
new bool[
data.size()];
143 unsigned int ind_tmp = 0;
146 for (
unsigned int ip = 0; ip <
data.size(); ++ip) {
149 for (
unsigned int it = 0; it <
data[ip].size(); ++it) {
153 v3.
np[nvar] =
data[ip][it].np[nvar] - 1;
157 if (!v3x.empty() || keep_empty) {
158 v3x.resize(v3x.size());
159 p_out.
data.push_back(v3x);
160 tmp_mask[ind_tmp] = is_off[ip];
167 p_out.
data.resize(p_out.
data.size());
196 for (
unsigned int ip = 0; ip <
data.size(); ++ip) {
197 for (
unsigned int it = 0; it <
data[ip].size(); ++it) {
198 p_out.
data[ip][it].coeff /= ++p_out.
data[ip][it].np[nvar];
211 copy(r_pow, r_pow + max_nr, p_out.
r_pow);
213 copy(z_pow, z_pow + max_nz, p_out.
z_pow);
216 p_out.
r_pow[max_nr] = p_out.
r_pow[max_nr - 1] * r_pow[1];
218 p_out.
z_pow[max_nz] = p_out.
z_pow[max_nz - 1] * z_pow[1];
231 for (
unsigned int ip = 0; ip <
data.size(); ++ip) {
234 for (
unsigned int it = 0; it <
data[ip].size(); ++it) {
235 data[ip][it].coeff *=
C;
245 for (
unsigned int ip = 0; ip <
data.size(); ++ip) {
248 for (
unsigned int it = 0; it <
data[ip].size(); ++it) {
249 data[ip][it].coeff *= *
C;
257 double rz_poly::GetSVal(
double r,
double z,
const double *
C)
const {
260 if (r_pow ==
nullptr)
263 double term, rez = 0.;
267 for (ip = 1; ip < max_nr; ++ip)
268 r_pow[ip] =
r * r_pow[ip - 1];
270 for (ip = 1; ip < max_nz; ++ip)
271 z_pow[ip] = z * z_pow[ip - 1];
273 for (ip = 0; ip < (
int)
data.size(); ++ip) {
278 term +=
data[ip][it].coeff * r_pow[
data[ip][it].np[0]] * z_pow[
data[ip][it].np[1]];
288 double *rz_poly::GetVVal(
double r,
double z,
double *rez_out) {
294 if (r_pow ==
nullptr)
304 rez =
new double[n_active];
309 for (ip = 1; ip < max_nr; ++ip)
310 r_pow[ip] =
r * r_pow[ip - 1];
312 for (ip = 1; ip < max_nz; ++ip)
313 z_pow[ip] = z * z_pow[ip - 1];
315 for (ip = 0; ip < (
int)
data.size(); ++ip) {
320 term +=
data[ip][it].coeff * r_pow[
data[ip][it].np[0]] * z_pow[
data[ip][it].np[1]];
330 double *rz_poly::Expand(
double *
C) {
335 double *rez =
new double[
data.size()];
336 for (
int ip = 0; ip < (
int)
data.size(); ++ip) {
Basic3DVector & operator*=(T t)
Scaling by a scalar value (multiplication)
std::vector< poly_term > poly_vect
char data[epos_bytes_allocation]