20 #include "headcpp.hpp"
21 #include "spheric_symphi.hpp"
22 #include "array_math.hpp"
24 #include "tensor_impl.hpp"
36 double fact_t, fact_r, fact_rt ;
60 cerr <<
"Unknow phi basis in Domain_nucleus_symphi::filter_val_domain" << endl ;
68 for (
int k=kmin ; k<=kmax ; k++) {
87 cerr <<
"Unknow phi basis in Domain_nucleus_symphi::filter_val_domain" << endl ;
103 if ((mquant==0) && (lquant==0)) {
104 if (fabs((*so.
cf)(pos_cf)) < threshold)
105 so.
cf->
set(pos_cf) = 0. ;
107 else if (mquant==0) {
111 pos_gal_r.
set(0) = 0 ;
114 fact_r = - pow(-1, i) ;
118 for (
int t=0 ; t<i ; t++)
119 fact_r *= -
double(2*t+1)/double(2*t+2) ;
123 cerr <<
"Strange base in Domain_nucleus_symphi::filter_val_domain" << endl ;
127 if (fabs((*so.
cf)(pos_cf)) < threshold) {
128 so.
cf->
set(pos_gal_r) -= fact_r*(*so.
cf)(pos_cf) ;
129 so.
cf->
set(pos_cf) = 0 ;
133 else if ((j!=0) && (i!=0)) {
136 pos_gal_r.
set(0) = 0 ;
138 pos_gal_t.
set(1) = 0 ;
139 pos_gal_rt = pos_cf ;
140 pos_gal_rt.
set(0) = 0 ;
141 pos_gal_rt.
set(1) = 0 ;
144 fact_r = -pow(-1, i) ;
146 fact_rt = pow(-1, i) ;
150 for (
int t=0 ; t<i ; t++)
151 l0 *= -
double(2*t+1)/double(2*t+2) ;
158 cerr <<
"Strange base in Domain_nucleus_symphi::filter_val_domain" << endl ;
161 if (fabs((*so.
cf)(pos_cf)) < threshold) {
162 so.
cf->
set(pos_gal_r) -= fact_r*(*so.
cf)(pos_cf) ;
163 so.
cf->
set(pos_gal_t) -= fact_t*(*so.
cf)(pos_cf) ;
164 so.
cf->
set(pos_gal_rt) -= fact_rt*(*so.
cf)(pos_cf) ;
165 so.
cf->
set(pos_cf) = 0 ;
172 if ((k==0) && (lquant<=1)) {
173 if (fabs((*so.
cf)(pos_cf)) < threshold)
174 so.
cf->
set(pos_cf) = 0. ;
177 if ((mquant==0) && (i!=0)) {
179 pos_gal_r.
set(0) = 0 ;
182 fact_r = - (2*i+1) * pow(-1, i) ;
186 for (
int t=0 ; t<i ; t++)
187 fact_r *= -
double(2*t+3)/double(2*t+2) ;
191 cerr <<
"Strange base in Domain_nucleus_symphi::filter_val_domain" << endl ;
195 if (fabs((*so.
cf)(pos_cf)) < threshold) {
196 so.
cf->
set(pos_gal_r) -= fact_r*(*so.
cf)(pos_cf) ;
197 so.
cf->
set(pos_cf) = 0 ;
200 else if ((j!=0) && (i!=0)) {
203 pos_gal_r.
set(0) = 0 ;
205 pos_gal_t.
set(1) = 0 ;
206 pos_gal_rt = pos_cf ;
207 pos_gal_rt.
set(0) = 0 ;
208 pos_gal_rt.
set(1) = 0 ;
211 fact_r = -pow(-1, i)*(2*i+1) ;
213 fact_rt = pow(-1, i)*(2*i+1) ;
217 for (
int t=0 ; t<i ; t++)
218 l0 *= -
double(2*t+3)/double(2*t+2) ;
225 cerr <<
"Strange base in Domain_nucleus_symphi::filter_val_domain" << endl ;
228 if (fabs((*so.
cf)(pos_cf)) < threshold) {
229 so.
cf->
set(pos_gal_r) -= fact_r*(*so.
cf)(pos_cf) ;
230 so.
cf->
set(pos_gal_t) -= fact_t*(*so.
cf)(pos_cf) ;
231 so.
cf->
set(pos_gal_rt) -= fact_rt*(*so.
cf)(pos_cf) ;
232 so.
cf->
set(pos_cf) = 0 ;
241 if ((mquant<=1) && (lquant==0)) {
242 if (fabs((*so.
cf)(pos_cf)) < threshold)
243 so.
cf->
set(pos_cf) = 0. ;
246 if ((mquant<=1) && (i!=0)) {
249 pos_gal_r.
set(0) = 0 ;
252 fact_r = - pow(-1, i) ;
256 for (
int t=0 ; t<i ; t++)
257 fact_r *= -
double(2*t+1)/double(2*t+2) ;
261 cerr <<
"Strange base in Domain_nucleus_symphi::filter_val_domain" << endl ;
264 if (fabs((*so.
cf)(pos_cf)) < threshold) {
265 so.
cf->
set(pos_gal_r) -= fact_r*(*so.
cf)(pos_cf) ;
266 so.
cf->
set(pos_cf) = 0 ;
271 if ((j!=1) && (i!=0)) {
274 pos_gal_r.
set(0) = 0 ;
276 pos_gal_t.
set(1) = 1 ;
277 pos_gal_rt = pos_cf ;
278 pos_gal_rt.
set(0) = 0 ;
279 pos_gal_rt.
set(1) = 1 ;
282 fact_r = -pow(-1, i) ;
284 fact_rt = pow(-1, i)*j ;
288 for (
int t=0 ; t<i ; t++)
289 l0 *= -
double(2*t+1)/double(2*t+2) ;
296 cerr <<
"Strange base in Domain_nucleus_symphi::filter_val_domain" << endl ;
299 if (fabs((*so.
cf)(pos_cf)) < threshold) {
300 so.
cf->
set(pos_gal_r) -= fact_r*(*so.
cf)(pos_cf) ;
301 so.
cf->
set(pos_gal_t) -= fact_t*(*so.
cf)(pos_cf) ;
302 so.
cf->
set(pos_gal_rt) -= fact_rt*(*so.
cf)(pos_cf) ;
303 so.
cf->
set(pos_cf) = 0 ;
313 if ((mquant<=1) && (lquant<=1)) {
314 if (fabs((*so.
cf)(pos_cf)) < threshold)
315 so.
cf->
set(pos_cf) = 0. ;
318 if ((mquant<=1) && (i!=0)) {
320 pos_gal_r.
set(0) = 0 ;
323 fact_r = - (2*i+1) * pow(-1, i) ;
327 for (
int t=0 ; t<i ; t++)
328 fact_r *= -
double(2*t+3)/double(2*t+2) ;
332 cerr <<
"Strange base in Domain_nucleus_symphi::filter_val_domain" << endl ;
335 if (fabs((*so.
cf)(pos_cf)) < threshold) {
336 so.
cf->
set(pos_gal_r) -= fact_r*(*so.
cf)(pos_cf) ;
337 so.
cf->
set(pos_cf) = 0 ;
340 else if ((j!=0) && (i!=0)) {
343 pos_gal_r.
set(0) = 0 ;
345 pos_gal_t.
set(1) = 0 ;
346 pos_gal_rt = pos_cf ;
347 pos_gal_rt.
set(0) = 0 ;
348 pos_gal_rt.
set(1) = 0 ;
351 fact_r = -pow(-1, i)*(2*i+1) ;
353 fact_rt = pow(-1, i)*(2*i+1)*(2*j+1) ;
357 for (
int t=0 ; t<i ; t++)
358 l0 *= -
double(2*t+3)/double(2*t+2) ;
361 fact_rt = l0*(2*j+1) ;
365 cerr <<
"Strange base in Domain_nucleus_symphi::filter_val_domain" << endl ;
368 if (fabs((*so.
cf)(pos_cf)) < threshold) {
369 so.
cf->
set(pos_gal_r) -= fact_r*(*so.
cf)(pos_cf) ;
370 so.
cf->
set(pos_gal_t) -= fact_t*(*so.
cf)(pos_cf) ;
371 so.
cf->
set(pos_gal_rt) -= fact_rt*(*so.
cf)(pos_cf) ;
372 so.
cf->
set(pos_cf) = 0 ;
379 cerr <<
"Unknow theta basis in Domain_nucleus_symphi::filter_val_domain" << endl ;
408 cerr <<
"Unknown type of vector Domain_nucleus_symphi::filter" << endl ;
439 cerr <<
"Unknown type of 2-tensor Domain_nucleus_symphi::filter" << endl ;
445 cerr <<
"Valence " << val <<
" not implemented in Domain_nucleus_symphi::filter" << endl ;
reference set(const Index &pos)
Read/write of an element.
Bases_container bases_1d
Arrays containing the various basis of decomposition.
int get_basis(int nd) const
Read only the basis in a given domain.
void filter_val_domain(Val_domain &so, double threshold) const
Sets to zero all the coefficients smaller than a given treshold.
virtual void filter(Tensor &tt, int dom, double threshold) const
Puts to zero all the coefficients below a given treshold.
Dim_array nbr_coefs
Number of coefficients.
Class that gives the position inside a multi-dimensional Array.
int & set(int i)
Read/write of the position in a given dimension.
Val_domain & set_domain(int)
Read/write of a particular Val_domain.
const Domain * get_domain(int i) const
returns a pointer on the domain.
Scalar & set(const Array< int > &ind)
Returns the value of a component (read/write version).
const Base_tensor & get_basis() const
Returns the vectorial basis (triad) on which the components are defined.
int get_n_comp() const
Returns the number of stored components.
int get_valence() const
Returns the valence.
const Space & get_space() const
Returns the Space.
Class for storing the basis of decompositions of a field and its values on both the configuration and...
Array< double > * cf
Pointer on the Array of the values in the coefficients space.
void coef() const
Computes the coefficients.
const Base_spectral & get_base() const
Returns the basis of decomposition.