112 assert (t1.
mp == t2.
mp) ;
116 Itbl tipe (val_res) ;
118 for (
int i=0 ; i<t1.
valence ; i++)
120 for (
int i=0 ; i<t2.
valence ; i++)
136 Tensor res(*t1.
mp, val_res, tipe, triad_res) ;
141 for (
int i=0 ; i<res.
n_comp ; i++) {
143 for (
int j=0 ; j<t1.
valence ; j++)
144 jeux_indice_t1.
set(j) = jeux_indice_res(j) ;
145 for (
int j=0 ; j<t2.
valence ; j++)
146 jeux_indice_t2.
set(j) = jeux_indice_res(j+t1.
valence) ;
148 res.
set(jeux_indice_res) = t1(jeux_indice_t1)*t2(jeux_indice_t2) ;
170 assert((ind1>=0) && (ind1<val1)) ;
171 assert((ind2>=0) && (ind2<val2)) ;
175 if ( (val1 != 0) && (val2 != 0) ) {
180 int val_res = val1 + val2 - 2;
184 for (
int i=0 ; i<ind1 ; i++)
186 for (
int i=ind1 ; i<val1-1 ; i++)
188 for (
int i=val1-1 ; i<val1+ind2-1 ; i++)
190 for (
int i = val1+ind2-1 ; i<val_res ; i++)
199 Itbl jeux_indice_t1(val1) ;
200 Itbl jeux_indice_t2(val2) ;
202 for (
int i=0 ; i<res.get_n_comp() ; i++) {
204 Itbl jeux_indice_res(res.indices(i)) ;
206 for (
int j=0 ; j<ind1 ; j++)
207 jeux_indice_t1.
set(j) = jeux_indice_res(j) ;
209 for (
int j=ind1+1 ; j<val1 ; j++)
210 jeux_indice_t1.set(j) = jeux_indice_res(j-1) ;
212 for (
int j=0 ; j<ind2 ; j++)
213 jeux_indice_t2.
set(j) = jeux_indice_res(val1+j-1) ;
215 for (
int j=ind2+1 ; j<val2 ; j++)
216 jeux_indice_t2.
set(j) = jeux_indice_res(val1+j-2) ;
218 Scalar& work = res.
set(jeux_indice_res) ;
221 for (
int j=1 ; j<=3 ; j++) {
222 jeux_indice_t1.set(ind1) = j ;
223 jeux_indice_t2.
set(ind2) = j ;
225 work += t1(jeux_indice_t1) % t2(jeux_indice_t2) ;
228 work += t1(jeux_indice_t1) * t2(jeux_indice_t2) ;
242 const Tensor& t2,
int i2,
int j2,
249 assert( val1 >= 2 ) ;
250 assert( val2 >= 2 ) ;
251 assert( (0<=i1) && (i1<j1) && (j1<val1) ) ;
252 assert( (0<=i2) && (i2<j2) && (j2<val2) ) ;
260 int val_res = val1 + val2 - 4 ;
264 for (
int i=0 ; i<i1 ; i++)
267 for (
int i=i1 ; i<j1-1 ; i++)
270 for (
int i=j1-1 ; i<val1-2 ; i++)
273 for (
int i=val1-2 ; i<val1-2+i2 ; i++)
276 for (
int i=val1-2+i2 ; i<val1+j2-3 ; i++)
279 for (
int i=val1+j2-3 ; i<val_res ; i++)
288 Itbl jeux_indice_t1(val1) ;
289 Itbl jeux_indice_t2(val2) ;
291 for (
int ic=0 ; ic<res.get_n_comp() ; ic++) {
293 Itbl jeux_indice_res(res.indices(ic)) ;
295 for (
int k=0 ; k<i1 ; k++)
296 jeux_indice_t1.
set(k) = jeux_indice_res(k) ;
298 for (
int k=i1+1 ; k<j1 ; k++)
299 jeux_indice_t1.set(k) = jeux_indice_res(k-1) ;
301 for (
int k=j1+1 ; k<val1 ; k++)
302 jeux_indice_t1.set(k) = jeux_indice_res(k-2) ;
304 for (
int k=0 ; k<i2 ; k++)
305 jeux_indice_t2.
set(k) = jeux_indice_res(val1+k-2) ;
307 for (
int k=i2+1 ; k<j2 ; k++)
308 jeux_indice_t2.
set(k) = jeux_indice_res(val1+k-3) ;
310 for (
int k=j2+1 ; k<val2 ; k++)
311 jeux_indice_t2.
set(k) = jeux_indice_res(val1+k-4) ;
313 Scalar& work = res.
set(jeux_indice_res) ;
316 for (
int i=1 ; i<=3 ; i++) {
318 jeux_indice_t1.set(i1) = i ;
319 jeux_indice_t2.
set(i2) = i ;
321 for (
int j=1 ; j<=3 ; j++) {
323 jeux_indice_t1.set(j1) = j ;
324 jeux_indice_t2.
set(j2) = j ;
327 work += t1(jeux_indice_t1) % t2(jeux_indice_t2) ;
330 work += t1(jeux_indice_t1) * t2(jeux_indice_t2) ;
348 assert ((ind_1 >= 0) && (ind_1 < val)) ;
349 assert ((ind_2 >= 0) && (ind_2 < val)) ;
350 assert (ind_1 != ind_2) ;
361 int val_res = val - 2 ;
365 for (
int i=0 ; i<ind_1 ; i++)
367 for (
int i=ind_1 ; i<ind_2-1 ; i++)
369 for (
int i = ind_2-1 ; i<val_res ; i++)
376 Itbl jeux_indice_source(val) ;
378 for (
int i=0 ; i<res.get_n_comp() ; i++) {
380 Itbl jeux_indice_res(res.indices(i)) ;
382 for (
int j=0 ; j<ind_1 ; j++)
383 jeux_indice_source.
set(j) = jeux_indice_res(j) ;
384 for (
int j=ind_1+1 ; j<ind_2 ; j++)
385 jeux_indice_source.set(j) = jeux_indice_res(j-1) ;
386 for (
int j=ind_2+1 ; j<val ; j++)
387 jeux_indice_source.set(j) = jeux_indice_res(j-2) ;
389 Scalar& work = res.
set(jeux_indice_res) ;
392 for (
int j=1 ; j<=3 ; j++) {
393 jeux_indice_source.set(ind_1) = j ;
394 jeux_indice_source.set(ind_2) = j ;
395 work += source(jeux_indice_source) ;
414 if (comment != 0x0) ost << comment <<
" : " << endl ;
425 if (n_comp_a >= n_comp_b) {
426 n_comp_max = n_comp_a ;
430 n_comp_max = n_comp_b ;
435 Tbl resu(n_comp_max, nz) ;
440 for (
int ic=0; ic<n_comp_max; ic++) {
444 if (n_comp_max > 1) ost <<
" Comp." ;
445 for (
int j=0 ; j<val ; j++) {
446 ost <<
" " << idx(j) ;
448 if (n_comp_max > 1) ost <<
" : " ;
450 for (
int l=0; l<nz; l++) {
451 ost <<
" " << diff(l) ;
452 resu.
set(ic, l) = diff(l) ;
470 if (comment != 0x0) ost << comment <<
" : " << endl ;
481 if (n_comp_a >= n_comp_b) {
482 n_comp_max = n_comp_a ;
486 n_comp_max = n_comp_b ;
491 Tbl resu(n_comp_max, nz) ;
496 for (
int ic=0; ic<n_comp_max; ic++) {
500 if (n_comp_max > 1) ost <<
" Comp." ;
501 for (
int j=0 ; j<val ; j++) {
502 ost <<
" " << idx(j) ;
504 if (n_comp_max > 1) ost <<
" : " ;
506 for (
int l=0; l<nz; l++) {
507 ost <<
" " << diff(l) ;
508 resu.
set(ic, l) = diff(l) ;
526 if (comment != 0x0) ost << comment <<
" : " << endl ;
533 Tbl resu(n_comp, nz) ;
538 for (
int ic=0; ic<n_comp; ic++) {
541 Tbl diff =
max( aa(idx) ) ;
543 if (val > 0) ost <<
" Comp." ;
544 for (
int j=0 ; j<val ; j++) {
545 ost <<
" " << idx(j) ;
547 if (val > 0) ost <<
" : " ;
549 for (
int l=0; l<nz; l++) {
550 ost <<
" " << diff(l) ;
551 resu.
set(ic, l) = diff(l) ;
569 if (comment != 0x0) ost << comment <<
" : " << endl ;
576 Tbl resu(n_comp, nz) ;
581 for (
int ic=0; ic<n_comp; ic++) {
584 Tbl diff =
min( aa(idx) ) ;
586 if (val > 0) ost <<
" Comp." ;
587 for (
int j=0 ; j<val ; j++) {
588 ost <<
" " << idx(j) ;
590 if (val > 0) ost <<
" : " ;
592 for (
int l=0; l<nz; l++) {
593 ost <<
" " << diff(l) ;
594 resu.
set(ic, l) = diff(l) ;
611 if (comment != 0x0) ost << comment <<
" : " << endl ;
618 Tbl resu(n_comp, nz) ;
623 for (
int ic=0; ic<n_comp; ic++) {
629 if (val > 0) ost <<
" Comp." ;
630 for (
int j=0 ; j<val ; j++) {
631 ost <<
" " << idx(j) ;
633 if (val > 0 ) ost <<
" : " ;
636 for (
int l=0; l<nz; l++) {
637 if (verb) ost <<
" " << diff(l) ;
638 resu.
set(ic, l) = diff(l) ;
640 if (verb) ost <<
"\n" ;
654 if (comment != 0x0) ost << comment <<
" : " << endl ;
664 for (
int ic=0; ic<n_comp; ic++) {
667 double aa_c = aa(idx).val_grid_point(0,0,0,0) ;
668 resu.
set(ic) = aa_c ;
670 if ( comment != 0x0 ) {
671 if ( val > 0 ) ost <<
" Comp." ;
672 for (
int j=0 ; j<val ; j++) {
673 ost <<
" " << idx(j) ;
675 if (val > 0 ) ost <<
" : " ;
677 ost << aa_c << endl ;
693 if (comment != 0x0) ost << comment <<
" : " << endl ;
706 for (
int ic=0; ic<n_comp; ic++) {
709 if (l_excluded != 0) x0 = max_dom(ic, 0) ;
710 else x0 = max_dom(ic, 1) ;
711 for (
int l=0; l<nz; l++) {
712 if (l == l_excluded) continue ;
713 double x = max_dom(ic,l) ;
719 if ( comment != 0x0 ) {
720 if ( val > 0 ) ost <<
" Comp." ;
722 for (
int j=0 ; j<val ; j++) {
723 ost <<
" " << idx(j) ;
725 if (val > 0 ) ost <<
" : " ;
743 if (comment != 0x0) ost << comment <<
" : " << endl ;
756 for (
int ic=0; ic<n_comp; ic++) {
759 if (l_excluded != 0) x0 = min_dom(ic, 0) ;
760 else x0 = min_dom(ic, 1) ;
761 for (
int l=0; l<nz; l++) {
762 if (l == l_excluded) continue ;
763 double x = min_dom(ic,l) ;
769 if ( comment != 0x0 ) {
770 if ( val > 0 ) ost <<
" Comp." ;
772 for (
int j=0 ; j<val ; j++) {
773 ost <<
" " << idx(j) ;
775 if (val > 0 ) ost <<
" : " ;
792 ostream& ost,
bool verb) {
794 if (comment != 0x0) ost << comment <<
" : " << endl ;
796 Tbl maxabs_dom =
maxabs(aa, 0x0, ost, verb) ;
807 for (
int ic=0; ic<n_comp; ic++) {
810 if (l_excluded != 0) x0 = maxabs_dom(ic, 0) ;
811 else x0 = maxabs_dom(ic, 1) ;
812 for (
int l=0; l<nz; l++) {
813 if (l == l_excluded) continue ;
814 double x = maxabs_dom(ic,l) ;
820 if ( comment != 0x0 ) {
821 if ( val > 0 ) ost <<
" Comp." ;
823 for (
int j=0 ; j<val ; j++) {
824 ost <<
" " << idx(j) ;
826 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 .