22 #include "tensor_impl.hpp"
26 cerr <<
"Names of indices must be affected in Tensor::do_summation" << endl ;
35 for (
int j=i+1 ; j<
valence ; j++) {
39 if ((nsame(i)>1) || (nsame(j)>1)) {
40 cerr <<
"Too many identical indices in Tensor::do_summation" << endl ;
46 cerr <<
"Can not sum on indices of the same type in Tensor::do_summation" << endl ;
58 if (valence_res > 0) {
60 char* name_ind_res =
new char[valence_res] ;
71 for (
int i=0 ; i<valence_res ; i++)
85 if (pos(sum_ind(i))!=pos(i))
92 pos_res.
set(conte)=pos(i) ;
99 first.
set(ind) = false ;
101 res.
set(pos_res) += (*this)(pos) ;
115 for (
int i=0 ; i<
valence ; i++)
116 if (pos(sum_ind(i))!=pos(i))
125 res += (*this)(pos) ;
136 for (
int d=0 ; d<
ndom ; d++)
140 indices_res.
set(0) = COV ;
141 for (
int i=0 ; i<
valence ; i++)
145 for (
int i=0 ; i<
ndim ; i++) {
146 indices_res.
set(0) = i+1 ;
147 for (
int j=0 ; j<
n_comp ; j++) {
149 for (
int k=0 ; k<
valence ; k++)
150 indices_res.
set(k+1) = cible(k) ;
reference set(const Index &pos)
Read/write of an element.
void set(Dim_array const &nbr_coefs, int basephi, int basetheta, int baser)
Allocates the various arrays, for a given number of coefficients and sets basis to some values (same ...
int get_basis(int nd) const
Read only the basis in a given domain.
Class that gives the position inside a multi-dimensional Array.
int & set(int i)
Read/write of the position in a given dimension.
bool inc(int increm, int var=0)
Increments the position of the Index.
The class Scalar does not really implements scalars in the mathematical sense but rather tensorial co...
Val_domain & set_domain(int)
Read/write of a particular Val_domain.
Scalar der_abs(int) const
Returns the derivative with respect to one particular absolute Cartesian coordinate.
int get_nbr_domains() const
Returns the number of Domains.
const Scalar & operator()() const
Read only for a Scalar.
bool name_affected
Indicator that states if the indices have been given names.
Memory_mapped_array< char > name_indice
If the indices haves names they are stored here.
Base_tensor basis
Tensorial basis with respect to which the tensor components are defined.
Tensor do_summation() const
Does the inner contraction of the Tensor.
int ndom
The number of Domain.
int valence
Valence of the tensor (0 = scalar, 1 = vector, etc...)
Tensor grad() const
Computes the flat gradient, in Cartesian coordinates.
Array< int > type_indice
1D array of integers of size valence containing the type of each index: COV for a covariant one and C...
Scalar & set(const Array< int > &ind)
Returns the value of a component (read/write version).
int get_n_comp() const
Returns the number of stored components.
virtual Array< int > indices(int pos) const
Gives the values of the indices corresponding to a location in the array used for storage of the comp...
int n_comp
Number of stored components, depending on the symmetry.
const Space & espace
The Space.
virtual int position(const Array< int > &idx) const
Gives the location of a given component in the array used for storage (Array version).
Base_spectral & set_base()
Sets the basis of decomposition.