115 assert (t1.
mp == t2.
mp) ;
119 Itbl tipe (val_res) ;
121 for (
int i=0 ; i<t1.
valence ; i++)
123 for (
int i=0 ; i<t2.
valence ; i++)
139 Tensor res(*t1.
mp, val_res, tipe, triad_res) ;
144 for (
int i=0 ; i<res.
n_comp ; i++) {
146 for (
int j=0 ; j<t1.
valence ; j++)
147 jeux_indice_t1.
set(j) = jeux_indice_res(j) ;
148 for (
int j=0 ; j<t2.
valence ; j++)
149 jeux_indice_t2.
set(j) = jeux_indice_res(j+t1.
valence) ;
151 res.
set(jeux_indice_res) = t1(jeux_indice_t1)*t2(jeux_indice_t2) ;
173 assert((ind1>=0) && (ind1<val1)) ;
174 assert((ind2>=0) && (ind2<val2)) ;
178 if ( (val1 != 0) && (val2 != 0) ) {
183 int val_res = val1 + val2 - 2;
187 for (
int i=0 ; i<ind1 ; i++)
189 for (
int i=ind1 ; i<val1-1 ; i++)
191 for (
int i=val1-1 ; i<val1+ind2-1 ; i++)
193 for (
int i = val1+ind2-1 ; i<val_res ; i++)
202 Itbl jeux_indice_t1(val1) ;
203 Itbl jeux_indice_t2(val2) ;
205 for (
int i=0 ; i<res.get_n_comp() ; i++) {
207 Itbl jeux_indice_res(res.indices(i)) ;
209 for (
int j=0 ; j<ind1 ; j++)
210 jeux_indice_t1.
set(j) = jeux_indice_res(j) ;
212 for (
int j=ind1+1 ; j<val1 ; j++)
213 jeux_indice_t1.set(j) = jeux_indice_res(j-1) ;
215 for (
int j=0 ; j<ind2 ; j++)
216 jeux_indice_t2.
set(j) = jeux_indice_res(val1+j-1) ;
218 for (
int j=ind2+1 ; j<val2 ; j++)
219 jeux_indice_t2.
set(j) = jeux_indice_res(val1+j-2) ;
221 Scalar& work = res.
set(jeux_indice_res) ;
224 for (
int j=1 ; j<=3 ; j++) {
225 jeux_indice_t1.set(ind1) = j ;
226 jeux_indice_t2.
set(ind2) = j ;
228 work += t1(jeux_indice_t1) | t2(jeux_indice_t2) ;
231 work += t1(jeux_indice_t1) * t2(jeux_indice_t2) ;
245 const Tensor& t2,
int i2,
int j2,
252 assert( val1 >= 2 ) ;
253 assert( val2 >= 2 ) ;
254 assert( (0<=i1) && (i1<j1) && (j1<val1) ) ;
255 assert( (0<=i2) && (i2<j2) && (j2<val2) ) ;
263 int val_res = val1 + val2 - 4 ;
267 for (
int i=0 ; i<i1 ; i++)
270 for (
int i=i1 ; i<j1-1 ; i++)
273 for (
int i=j1-1 ; i<val1-2 ; i++)
276 for (
int i=val1-2 ; i<val1-2+i2 ; i++)
279 for (
int i=val1-2+i2 ; i<val1+j2-3 ; i++)
282 for (
int i=val1+j2-3 ; i<val_res ; i++)
291 Itbl jeux_indice_t1(val1) ;
292 Itbl jeux_indice_t2(val2) ;
294 for (
int ic=0 ; ic<res.get_n_comp() ; ic++) {
296 Itbl jeux_indice_res(res.indices(ic)) ;
298 for (
int k=0 ; k<i1 ; k++)
299 jeux_indice_t1.
set(k) = jeux_indice_res(k) ;
301 for (
int k=i1+1 ; k<j1 ; k++)
302 jeux_indice_t1.set(k) = jeux_indice_res(k-1) ;
304 for (
int k=j1+1 ; k<val1 ; k++)
305 jeux_indice_t1.set(k) = jeux_indice_res(k-2) ;
307 for (
int k=0 ; k<i2 ; k++)
308 jeux_indice_t2.
set(k) = jeux_indice_res(val1+k-2) ;
310 for (
int k=i2+1 ; k<j2 ; k++)
311 jeux_indice_t2.
set(k) = jeux_indice_res(val1+k-3) ;
313 for (
int k=j2+1 ; k<val2 ; k++)
314 jeux_indice_t2.
set(k) = jeux_indice_res(val1+k-4) ;
316 Scalar& work = res.
set(jeux_indice_res) ;
319 for (
int i=1 ; i<=3 ; i++) {
321 jeux_indice_t1.set(i1) = i ;
322 jeux_indice_t2.
set(i2) = i ;
324 for (
int j=1 ; j<=3 ; j++) {
326 jeux_indice_t1.set(j1) = j ;
327 jeux_indice_t2.
set(j2) = j ;
330 work += t1(jeux_indice_t1) | t2(jeux_indice_t2) ;
333 work += t1(jeux_indice_t1) * t2(jeux_indice_t2) ;
351 assert ((ind_1 >= 0) && (ind_1 < val)) ;
352 assert ((ind_2 >= 0) && (ind_2 < val)) ;
353 assert (ind_1 != ind_2) ;
364 int val_res = val - 2 ;
368 for (
int i=0 ; i<ind_1 ; i++)
370 for (
int i=ind_1 ; i<ind_2-1 ; i++)
372 for (
int i = ind_2-1 ; i<val_res ; i++)
379 Itbl jeux_indice_source(val) ;
381 for (
int i=0 ; i<res.get_n_comp() ; i++) {
383 Itbl jeux_indice_res(res.indices(i)) ;
385 for (
int j=0 ; j<ind_1 ; j++)
386 jeux_indice_source.
set(j) = jeux_indice_res(j) ;
387 for (
int j=ind_1+1 ; j<ind_2 ; j++)
388 jeux_indice_source.set(j) = jeux_indice_res(j-1) ;
389 for (
int j=ind_2+1 ; j<val ; j++)
390 jeux_indice_source.set(j) = jeux_indice_res(j-2) ;
392 Scalar& work = res.
set(jeux_indice_res) ;
395 for (
int j=1 ; j<=3 ; j++) {
396 jeux_indice_source.set(ind_1) = j ;
397 jeux_indice_source.set(ind_2) = j ;
398 work += source(jeux_indice_source) ;
417 if (comment != 0x0) ost << comment <<
" : " << endl ;
428 if (n_comp_a >= n_comp_b) {
429 n_comp_max = n_comp_a ;
433 n_comp_max = n_comp_b ;
438 Tbl resu(n_comp_max, nz) ;
443 for (
int ic=0; ic<n_comp_max; ic++) {
447 if (n_comp_max > 1) ost <<
" Comp." ;
448 for (
int j=0 ; j<val ; j++) {
449 ost <<
" " << idx(j) ;
451 if (n_comp_max > 1) ost <<
" : " ;
453 for (
int l=0; l<nz; l++) {
454 ost <<
" " << diff(l) ;
455 resu.
set(ic, l) = diff(l) ;
473 if (comment != 0x0) ost << comment <<
" : " << endl ;
484 if (n_comp_a >= n_comp_b) {
485 n_comp_max = n_comp_a ;
489 n_comp_max = n_comp_b ;
494 Tbl resu(n_comp_max, nz) ;
499 for (
int ic=0; ic<n_comp_max; ic++) {
503 if (n_comp_max > 1) ost <<
" Comp." ;
504 for (
int j=0 ; j<val ; j++) {
505 ost <<
" " << idx(j) ;
507 if (n_comp_max > 1) ost <<
" : " ;
509 for (
int l=0; l<nz; l++) {
510 ost <<
" " << diff(l) ;
511 resu.
set(ic, l) = diff(l) ;
529 if (comment != 0x0) ost << comment <<
" : " << endl ;
536 Tbl resu(n_comp, nz) ;
541 for (
int ic=0; ic<n_comp; ic++) {
544 Tbl diff =
max( aa(idx) ) ;
546 if (val > 0) ost <<
" Comp." ;
547 for (
int j=0 ; j<val ; j++) {
548 ost <<
" " << idx(j) ;
550 if (val > 0) ost <<
" : " ;
552 for (
int l=0; l<nz; l++) {
553 ost <<
" " << diff(l) ;
554 resu.
set(ic, l) = diff(l) ;
572 if (comment != 0x0) ost << comment <<
" : " << endl ;
579 Tbl resu(n_comp, nz) ;
584 for (
int ic=0; ic<n_comp; ic++) {
587 Tbl diff =
min( aa(idx) ) ;
589 if (val > 0) ost <<
" Comp." ;
590 for (
int j=0 ; j<val ; j++) {
591 ost <<
" " << idx(j) ;
593 if (val > 0) ost <<
" : " ;
595 for (
int l=0; l<nz; l++) {
596 ost <<
" " << diff(l) ;
597 resu.
set(ic, l) = diff(l) ;
614 if (comment != 0x0) ost << comment <<
" : " << endl ;
621 Tbl resu(n_comp, nz) ;
626 for (
int ic=0; ic<n_comp; ic++) {
632 if (val > 0) ost <<
" Comp." ;
633 for (
int j=0 ; j<val ; j++) {
634 ost <<
" " << idx(j) ;
636 if (val > 0 ) ost <<
" : " ;
639 for (
int l=0; l<nz; l++) {
640 if (verb) ost <<
" " << diff(l) ;
641 resu.
set(ic, l) = diff(l) ;
643 if (verb) ost <<
"\n" ;
657 if (comment != 0x0) ost << comment <<
" : " << endl ;
667 for (
int ic=0; ic<n_comp; ic++) {
670 double aa_c = aa(idx).val_grid_point(0,0,0,0) ;
671 resu.
set(ic) = aa_c ;
673 if ( comment != 0x0 ) {
674 if ( val > 0 ) ost <<
" Comp." ;
675 for (
int j=0 ; j<val ; j++) {
676 ost <<
" " << idx(j) ;
678 if (val > 0 ) ost <<
" : " ;
680 ost << aa_c << endl ;
696 if (comment != 0x0) ost << comment <<
" : " << endl ;
709 for (
int ic=0; ic<n_comp; ic++) {
712 if (l_excluded != 0) x0 = max_dom(ic, 0) ;
713 else x0 = max_dom(ic, 1) ;
714 for (
int l=0; l<nz; l++) {
715 if (l == l_excluded) continue ;
716 double x = max_dom(ic,l) ;
722 if ( comment != 0x0 ) {
723 if ( val > 0 ) ost <<
" Comp." ;
725 for (
int j=0 ; j<val ; j++) {
726 ost <<
" " << idx(j) ;
728 if (val > 0 ) ost <<
" : " ;
746 if (comment != 0x0) ost << comment <<
" : " << endl ;
759 for (
int ic=0; ic<n_comp; ic++) {
762 if (l_excluded != 0) x0 = min_dom(ic, 0) ;
763 else x0 = min_dom(ic, 1) ;
764 for (
int l=0; l<nz; l++) {
765 if (l == l_excluded) continue ;
766 double x = min_dom(ic,l) ;
772 if ( comment != 0x0 ) {
773 if ( val > 0 ) ost <<
" Comp." ;
775 for (
int j=0 ; j<val ; j++) {
776 ost <<
" " << idx(j) ;
778 if (val > 0 ) ost <<
" : " ;
795 ostream& ost,
bool verb) {
797 if (comment != 0x0) ost << comment <<
" : " << endl ;
799 Tbl maxabs_dom =
maxabs(aa, 0x0, ost, verb) ;
810 for (
int ic=0; ic<n_comp; ic++) {
813 if (l_excluded != 0) x0 = maxabs_dom(ic, 0) ;
814 else x0 = maxabs_dom(ic, 1) ;
815 for (
int l=0; l<nz; l++) {
816 if (l == l_excluded) continue ;
817 double x = maxabs_dom(ic,l) ;
823 if ( comment != 0x0 ) {
824 if ( val > 0 ) ost <<
" Comp." ;
826 for (
int j=0 ; j<val ; j++) {
827 ost <<
" " << idx(j) ;
829 if (val > 0 ) ost <<
" : " ;
Tbl maxabs(const Tensor &aa, const char *comment=0x0, ostream &ost=cout, bool verb=true)
Maxima in each domain of the absolute values of the tensor components.
Tbl min_all_domains(const Tensor &aa, int l_excluded=-1, const char *comment=0x0, ostream &ost=cout)
Minimum value of each component of a tensor over all the domains.
int & set(int i)
Read/write of a particular element (index i ) (1D case)
int n_comp
Number of stored components, depending on the symmetry.
virtual void set_etat_zero()
Sets the logical state to ETATZERO (zero).
Tbl central_value(const Tensor &aa, const char *comment=0x0, ostream &ost=cout)
Central value of each component of a tensor.
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
double & set(int i)
Read/write of a particular element (index i) (1D case)
Tensor field of valence 0 (or component of a tensorial field).
Base_val operator*(const Base_val &, const Base_val &)
This operator is used when calling multiplication or division of Valeur .
int get_n_comp() const
Returns the number of stored components.
Basic integer array class.
Tbl min(const Cmp &)
Minimum values of a Cmp in each domain.
Vectorial bases (triads) with respect to which the tensorial components are defined.
Tbl diffrel(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (norme version).
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Itbl type_indice
1D array of integers (class Itbl ) of size valence containing the type of each index: COV for a cova...
const Base_vect * get_triad() const
Returns the vectorial basis (triad) on which the components are defined.
Tbl maxabs_all_domains(const Tensor &aa, int l_excluded=-1, const char *comment=0x0, ostream &ost=cout, bool verb=true)
Maximum of the absolute value of each component of a tensor over all the domains. ...
Tbl max_all_domains(const Tensor &aa, int l_excluded=-1, const char *comment=0x0, ostream &ost=cout)
Maximum value of each component of a tensor over all the domains.
int get_index_type(int i) const
Gives the type (covariant or contravariant) of the index number i .
int get_nzone() const
Returns the number of domains.
Tbl max(const Cmp &)
Maximum values of a Cmp in each domain.
Tenseur contract(const Tenseur &, int id1, int id2)
Self contraction of two indices of a Tenseur .
int get_valence() const
Returns the valence.
int valence
Valence of the tensor (0 = scalar, 1 = vector, etc...)
Scalar & set(const Itbl &ind)
Returns the value of a component (read/write version).
Cmp abs(const Cmp &)
Absolute value.
const Map *const mp
Mapping on which the numerical values at the grid points are defined.
const Map & get_mp() const
Returns the mapping.
Tbl diffrelmax(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (max version).
virtual Itbl indices(int pos) const
Returns the indices of a component given by its position in the array cmp .