20 #include "headcpp.hpp"
22 #include "spheric.hpp"
24 #include "tensor_impl.hpp"
37 double fact_t, fact_r, fact_rt ;
46 assert (baset==COS_EVEN) ;
47 for (
int j=0 ; j<2 ; j++) {
50 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
55 so.
cf->
set(pos_cf) = 1. ;
66 assert (baset==COS_EVEN) ;
70 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
74 pos_gal_r.
set(0) = 0 ;
77 fact_r = - (2*i+1) * pow(-1, i) ;
81 for (
int t=0 ; t<i ; t++)
82 fact_r *= -
double(2*t+3)/double(2*t+2) ;
86 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_cart" << endl ;
91 so.
cf->
set(pos_cf) = 1 ;
92 so.
cf->
set(pos_gal_r) += fact_r ;
103 int mquant = (k%2==0) ?
int(k/2) : int((k-1)/2) ;
108 assert (baset=COS_EVEN) ;
112 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
116 pos_gal_r.
set(0) = 0 ;
118 pos_gal_t.
set(1) = 0 ;
119 pos_gal_rt = pos_cf ;
120 pos_gal_rt.
set(0) = 0 ;
121 pos_gal_rt.
set(1) = 0 ;
124 fact_r = -pow(-1, i)*(2*i+1) ;
126 fact_rt = pow(-1, i)*(2*i+1) ;
130 for (
int t=0 ; t<i ; t++)
131 l0 *= -
double(2*t+3)/double(2*t+2) ;
138 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_cart" << endl ;
144 so.
cf->
set(pos_cf) = 1. ;
145 so.
cf->
set(pos_gal_r) += fact_r ;
146 so.
cf->
set(pos_gal_t) += fact_t ;
147 so.
cf->
set(pos_gal_rt) += fact_rt ;
155 assert (baset=SIN_ODD) ;
159 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
163 pos_gal_r.
set(0) = 0 ;
166 fact_r = - pow(-1, i) ;
170 for (
int t=0 ; t<i ; t++)
171 fact_r *= -
double(2*t+1)/double(2*t+2) ;
175 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vr" << endl ;
180 so.
cf->
set(pos_cf) = 1. ;
181 so.
cf->
set(pos_gal_r) += fact_r ;
207 double fact_t, fact_r, fact_rt ;
213 assert (baset==SIN_EVEN) ;
217 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
221 pos_gal_r.
set(0) = 0 ;
224 fact_r = - (2*i+1) * pow(-1, i) ;
228 for (
int t=0 ; t<i ; t++)
229 fact_r *= -
double(2*t+3)/double(2*t+2) ;
233 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vt" << endl ;
238 so.
cf->
set(pos_cf) = 1. ;
239 so.
cf->
set(pos_gal_r) += fact_r ;
252 assert (baset==COS_ODD) ;
255 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
260 so.
cf->
set(pos_cf) = 1. ;
271 assert (baset=COS_ODD) ;
275 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
277 pos_cf.
set(0) = i ;pos_gal_r = pos_cf ;
278 pos_gal_r.
set(0) = 0 ;
281 fact_r = - pow(-1, i) ;
285 for (
int t=0 ; t<i ; t++)
286 fact_r *= -
double(2*t+1)/double(2*t+2) ;
290 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vt" << endl ;
295 so.
cf->
set(pos_cf) = 1 ;
296 so.
cf->
set(pos_gal_r) += fact_r ;
309 assert (baset==COS_ODD) ;
312 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
317 so.
cf->
set(pos_cf) = 1. ;
329 assert (baset=COS_ODD) ;
333 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
337 pos_gal_r.
set(0) = 0 ;
340 fact_r = - pow(-1, i) ;
344 for (
int t=0 ; t<i ; t++)
345 fact_r *= -
double(2*t+1)/double(2*t+2) ;
349 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vt" << endl ;
354 so.
cf->
set(pos_cf) = 1 ;
355 so.
cf->
set(pos_gal_r) += fact_r ;
365 int mquant = (k%2==0) ?
int(k/2) : int((k-1)/2) ;
370 assert (baset=SIN_EVEN) ;
374 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
378 pos_gal_r.
set(0) = 0 ;
381 fact_r = - (2*i+1) * pow(-1, i) ;
385 for (
int t=0 ; t<i ; t++)
386 fact_r *= -
double(2*t+3)/double(2*t+2) ;
390 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vt" << endl ;
395 so.
cf->
set(pos_cf) = 1 ;
396 so.
cf->
set(pos_gal_r) += fact_r ;
404 assert (baset=COS_ODD) ;
408 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
412 pos_gal_r.
set(0) = 0 ;
414 pos_gal_t.
set(1) = 0 ;
415 pos_gal_rt = pos_cf ;
416 pos_gal_rt.
set(0) = 0 ;
417 pos_gal_rt.
set(1) = 0 ;
420 fact_r = -pow(-1, i) ;
422 fact_rt = pow(-1, i) ;
426 for (
int t=0 ; t<i ; t++)
427 l0 *= -
double(2*t+1)/double(2*t+2) ;
434 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vt" << endl ;
439 so.
cf->
set(pos_cf) = 1 ;
440 so.
cf->
set(pos_gal_r) += fact_r ;
441 so.
cf->
set(pos_gal_t) += fact_t ;
442 so.
cf->
set(pos_gal_rt) += fact_rt ;
467 double fact_t, fact_r, fact_rt ;
473 assert (baset==SIN_ODD) ;
476 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
481 so.
cf->
set(pos_cf) = 1 ;
491 assert (baset=SIN_ODD) ;
495 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
499 pos_gal_r.
set(0) = 0 ;
502 fact_r = - (2*i+1) * pow(-1, i) ;
506 for (
int t=0 ; t<i ; t++)
507 fact_r *= -
double(2*t+3)/double(2*t+2) ;
511 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vp" << endl ;
516 so.
cf->
set(pos_cf) = 1 ;
517 so.
cf->
set(pos_gal_r) += fact_r ;
531 assert (baset==COS_EVEN) ;
534 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
539 so.
cf->
set(pos_cf) = 1. ;
550 assert (baset=COS_EVEN) ;
554 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
556 pos_cf.
set(0) = i ;pos_gal_r = pos_cf ;
557 pos_gal_r.
set(0) = 0 ;
560 fact_r = - pow(-1, i) ;
564 for (
int t=0 ; t<i ; t++)
565 fact_r *= -
double(2*t+1)/double(2*t+2) ;
569 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vp" << endl ;
575 so.
cf->
set(pos_cf) = 1 ;
576 so.
cf->
set(pos_gal_r) += fact_r ;
589 assert (baset==COS_EVEN) ;
592 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
597 so.
cf->
set(pos_cf) = 1. ;
608 assert (baset=COS_EVEN) ;
612 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
616 pos_gal_r.
set(0) = 0 ;
619 fact_r = - pow(-1, i) ;
623 for (
int t=0 ; t<i ; t++)
624 fact_r *= -
double(2*t+1)/double(2*t+2) ;
628 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vp" << endl ;
633 so.
cf->
set(pos_cf) = 1 ;
634 so.
cf->
set(pos_gal_r) += fact_r ;
646 assert (baset==SIN_ODD) ;
649 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
654 so.
cf->
set(pos_cf) = 1 ;
665 assert (baset=SIN_ODD) ;
669 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
673 pos_gal_r.
set(0) = 0 ;
676 fact_r = - (2*i+1) * pow(-1, i) ;
680 for (
int t=0 ; t<i ; t++)
681 fact_r *= -
double(2*t+3)/double(2*t+2) ;
685 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vp" << endl ;
690 so.
cf->
set(pos_cf) = 1 ;
691 so.
cf->
set(pos_gal_r) += fact_r ;
704 assert (baset==SIN_ODD) ;
707 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
712 so.
cf->
set(pos_cf) = 1 ;
723 assert (baset=SIN_ODD) ;
727 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
731 pos_gal_r.
set(0) = 0 ;
734 fact_r = - (2*i+1) * pow(-1, i) ;
738 for (
int t=0 ; t<i ; t++)
739 fact_r *= -
double(2*t+3)/double(2*t+2) ;
743 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vp" << endl ;
748 so.
cf->
set(pos_cf) = 1 ;
749 so.
cf->
set(pos_gal_r) += fact_r ;
760 int mquant = (k%2==0) ?
int(k/2) : int((k-1)/2) ;
766 assert (baset=SIN_ODD) ;
770 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
774 pos_gal_r.
set(0) = 0 ;
777 fact_r = - (2*i+1) * pow(-1, i) ;
781 for (
int t=0 ; t<i ; t++)
782 fact_r *= -
double(2*t+3)/double(2*t+2) ;
786 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vp" << endl ;
791 so.
cf->
set(pos_cf) = 1 ;
792 so.
cf->
set(pos_gal_r) += fact_r ;
801 assert (baset=COS_EVEN) ;
805 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
809 pos_gal_r.
set(0) = 0 ;
811 pos_gal_t.
set(1) = 0 ;
812 pos_gal_rt = pos_cf ;
813 pos_gal_rt.
set(0) = 0 ;
814 pos_gal_rt.
set(1) = 0 ;
817 fact_r = -pow(-1, i) ;
819 fact_rt = pow(-1, i) ;
823 for (
int t=0 ; t<i ; t++)
824 l0 *= -
double(2*t+1)/double(2*t+2) ;
831 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vp" << endl ;
836 so.
cf->
set(pos_cf) = 1 ;
837 so.
cf->
set(pos_gal_r) += fact_r ;
838 so.
cf->
set(pos_gal_t) += fact_t ;
839 so.
cf->
set(pos_gal_rt) += fact_rt ;
856 int kmin = 2*mlim+2 ;
870 double fact_t, fact_r, fact_rt ;
888 if ((k<kmin) && (lquant<=llim)) {
891 so.
cf->
set(pos_cf) = 1. ;
901 pos_gal_r.
set(0) = 0 ;
904 fact_r = - pow(-1, i) ;
908 for (
int t=0 ; t<i ; t++)
909 fact_r *= -
double(2*t+1)/double(2*t+2) ;
913 cerr <<
"Strange base in Domain_nucleus::affecte_one_coef_val_domain" << endl ;
916 so.
cf->
set(pos_cf) = 1 ;
917 so.
cf->
set(pos_gal_r) += fact_r ;
922 else if ((j!=0) && (i!=0)) {
927 pos_gal_r.
set(0) = 0 ;
929 pos_gal_t.
set(1) = 0 ;
930 pos_gal_rt = pos_cf ;
931 pos_gal_rt.
set(0) = 0 ;
932 pos_gal_rt.
set(1) = 0 ;
935 fact_r = -pow(-1, i) ;
937 fact_rt = pow(-1, i) ;
941 for (
int t=0 ; t<i ; t++)
942 l0 *= -
double(2*t+1)/double(2*t+2) ;
949 cerr <<
"Strange base in Domain_nucleus::affecte_one_coef_val_domain" << endl ;
952 so.
cf->
set(pos_cf) = 1. ;
953 so.
cf->
set(pos_gal_r) = fact_r ;
954 so.
cf->
set(pos_gal_t) = fact_t ;
955 so.
cf->
set(pos_gal_rt) = fact_rt ;
963 if ((k<kmin) && (lquant<=llim+1)) {
966 so.
cf->
set(pos_cf) = 1. ;
971 if ((k<kmin) && (i!=0)) {
975 pos_gal_r.
set(0) = 0 ;
978 fact_r = - (2*i+1) * pow(-1, i) ;
982 for (
int t=0 ; t<i ; t++)
983 fact_r *= -
double(2*t+3)/double(2*t+2) ;
987 cerr <<
"Strange base in Domain_nucleus::affecte_one_coef_val_domain" << endl ;
991 so.
cf->
set(pos_cf) = 1. ;
992 so.
cf->
set(pos_gal_r) = fact_r ;
996 else if ((j!=0) && (i!=0)) {
1000 pos_gal_r = pos_cf ;
1001 pos_gal_r.
set(0) = 0 ;
1002 pos_gal_t = pos_cf ;
1003 pos_gal_t.
set(1) = 0 ;
1004 pos_gal_rt = pos_cf ;
1005 pos_gal_rt.
set(0) = 0 ;
1006 pos_gal_rt.
set(1) = 0 ;
1009 fact_r = -pow(-1, i)*(2*i+1) ;
1011 fact_rt = pow(-1, i)*(2*i+1) ;
1015 for (
int t=0 ; t<i ; t++)
1016 l0 *= -
double(2*t+3)/double(2*t+2) ;
1023 cerr <<
"Strange base in Domain_nucleus::affecte_one_coef_val_domain" << endl ;
1026 so.
cf->
set(pos_cf) = 1. ;
1027 so.
cf->
set(pos_gal_r) = fact_r ;
1028 so.
cf->
set(pos_gal_t) = fact_t ;
1029 so.
cf->
set(pos_gal_rt) = fact_rt ;
1039 if ((k<kmin+2) && (lquant<=llim)) {
1042 so.
cf->
set(pos_cf) = 1. ;
1047 if ((k<kmin+2) && (i!=0)) {
1051 pos_gal_r = pos_cf ;
1052 pos_gal_r.
set(0) = 0 ;
1055 fact_r = - pow(-1, i) ;
1059 for (
int t=0 ; t<i ; t++)
1060 fact_r *= -
double(2*t+1)/double(2*t+2) ;
1064 cerr <<
"Strange base in Domain_nucleus_::affecte_one_coef_val_domain" << endl ;
1067 so.
cf->
set(pos_cf) = 1. ;
1068 so.
cf->
set(pos_gal_r) = fact_r ;
1074 if ((j!=1) && (i!=0)) {
1079 pos_gal_r = pos_cf ;
1080 pos_gal_r.
set(0) = 0 ;
1081 pos_gal_t = pos_cf ;
1082 pos_gal_t.
set(1) = 1 ;
1083 pos_gal_rt = pos_cf ;
1084 pos_gal_rt.
set(0) = 0 ;
1085 pos_gal_rt.
set(1) = 1 ;
1088 fact_r = -pow(-1, i) ;
1090 fact_rt = pow(-1, i)*j ;
1094 for (
int t=0 ; t<i ; t++)
1095 l0 *= -
double(2*t+1)/double(2*t+2) ;
1102 cerr <<
"Strange base in Domain_nucleus::affecte_one_domain_val_domain" << endl ;
1105 so.
cf->
set(pos_cf) = 1 ;
1106 so.
cf->
set(pos_gal_r) = fact_r ;
1107 so.
cf->
set(pos_gal_t) = fact_t ;
1108 so.
cf->
set(pos_gal_rt) = fact_rt ;
1119 if ((k<kmin+2) && (lquant<=llim+1)) {
1122 so.
cf->
set(pos_cf) = 1. ;
1127 if ((k<kmin+2) && (i!=0)) {
1130 pos_gal_r = pos_cf ;
1131 pos_gal_r.
set(0) = 0 ;
1134 fact_r = - (2*i+1) * pow(-1, i) ;
1138 for (
int t=0 ; t<i ; t++)
1139 fact_r *= -
double(2*t+3)/double(2*t+2) ;
1143 cerr <<
"Strange base in Domain_nucleus::affecte_one_coef_val_domain" << endl ;
1147 so.
cf->
set(pos_cf) = 1. ;
1148 so.
cf->
set(pos_gal_r) = fact_r ;
1152 else if ((j!=0) && (i!=0)) {
1156 pos_gal_r = pos_cf ;
1157 pos_gal_r.
set(0) = 0 ;
1158 pos_gal_t = pos_cf ;
1159 pos_gal_t.
set(1) = 0 ;
1160 pos_gal_rt = pos_cf ;
1161 pos_gal_rt.
set(0) = 0 ;
1162 pos_gal_rt.
set(1) = 0 ;
1165 fact_r = -pow(-1, i)*(2*i+1) ;
1167 fact_rt = pow(-1, i)*(2*i+1)*(2*j+1) ;
1171 for (
int t=0 ; t<i ; t++)
1172 l0 *= -
double(2*t+3)/double(2*t+2) ;
1175 fact_rt = l0*(2*j+1) ;
1179 cerr <<
"Strange base in Domain_nucleus::affecte_one_coef_val_domain" << endl ;
1182 so.
cf->
set(pos_cf) = 1. ;
1183 so.
cf->
set(pos_gal_r) = fact_r ;
1184 so.
cf->
set(pos_gal_t) = fact_t ;
1185 so.
cf->
set(pos_gal_rt) = fact_rt ;
1193 cerr <<
"Unknow theta basis in Domain_nucleus::affecte_coef_val_domain" << endl ;
1215 bool found = false ;
1231 cerr <<
"Unknown type of vector Domain_nucleus::affecte_tau_one_coef" << endl ;
1237 bool found = false ;
1262 cerr <<
"Unknown type of 2-tensor Domain_nucleus::affecte_tau_one_coef" << endl ;
1268 cerr <<
"Valence " << val <<
" not implemented in Domain_nucleus::affecte_tau" << 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 affecte_tau_one_coef_val_domain(Val_domain &so, int mlim, int llim, int cc, int &pos_cf) const
Sets at most one coefficient of a Val_domain to 1.
void affecte_tau_one_coef_val_domain_vp(Val_domain &so, int cc, int &pos_cf) const
Sets at most one coefficient of a Val_domain to 1.
virtual void affecte_tau_one_coef(Tensor &, int, int, int &) const
Sets at most one coefficient of a Tensor to 1.
void affecte_tau_one_coef_val_domain_vr(Val_domain &so, int cc, int &pos_cf) const
Sets at most one coefficient of a Val_domain to 1.
void affecte_tau_one_coef_val_domain_vt(Val_domain &so, int cc, int &pos_cf) const
Sets at most one coefficient of a Val_domain to 1.
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...
void set_zero()
Sets the Val_domain to zero (logical state to zero and arrays destroyed).
void allocate_coef()
Allocates the values in the coefficient space and destroys the values in the configuration space.
Array< double > * cf
Pointer on the Array of the values in the coefficients space.
bool is_zero
Indicator used for null fields (for speed issues).
const Base_spectral & get_base() const
Returns the basis of decomposition.