KADATH
Kadath::Tensor Class Reference

Tensor handling. More...

#include <tensor.hpp>

Inheritance diagram for Kadath::Tensor:
Kadath::Metric_tensor Kadath::Scalar Kadath::Vector

Public Member Functions

 Tensor (const Space &sp, int val, const Array< int > &tipe, const Base_tensor &ba)
 Constructor. More...
 
 Tensor (const Space &sp, int val, int tipe, const Base_tensor &ba)
 Constructor where all the indices are of the same type. More...
 
 Tensor (const Space &sp, int val, const Array< int > &tipe, const Base_tensor &ba, int dim)
 Constructor assuming the dimension of the space and the tensor is different (for dealing with symmetries) More...
 
 Tensor (const Space &sp, int val, int tipe, const Base_tensor &ba, int dim)
 Constructor where all the indices are of the same type. More...
 
 Tensor (const Tensor &so, bool copie=true)
 Constructor by copy. More...
 
 Tensor (const Space &sp, FILE *)
 Constructor from a file. More...
 
 Tensor (const Space &sp, int dim, FILE *)
 Constructor from a file with explicit passing of the dimension. More...
 
void swap (Tensor &) noexcept
 Swap method. More...
 
virtual ~Tensor ()
 Destructor. More...
 
virtual void save (FILE *) const
 Saving operator. More...
 
const Param_tensorget_parameters () const
 Returns a pointer on the possible additional parameter. More...
 
Param_tensorset_parameters ()
 Read/write of the parameters. More...
 
void affect_parameters ()
 The function affect_parameters is deprecated and actually does nothing since the parameters are now always stored in order to lower usage of the memory heap. More...
 
bool is_m_order_affected () const
 Checks whether the additional parameter order is affected (not very used). More...
 
bool is_m_quant_affected () const
 Checks whether the additional parameter $m$ is affected (used for boson stars for instance). More...
 
int & set_basis (int dd)
 Assigns a new tensorial basis in a given domain. More...
 
virtual Tensoroperator= (const Tensor &)
 Assignment to a Tensor. More...
 
virtual Tensoroperator= (double xx)
 Assignment to a double (the same value for all the components at all the collocation points). More...
 
virtual void annule_hard ()
 Sets the Tensor to zero (hard version ; no logical state used). More...
 
Scalarset (const Array< int > &ind)
 Returns the value of a component (read/write version). More...
 
Scalarset (const Index &ind)
 Returns the value of a component (read/write version). More...
 
Scalarset ()
 Read/write for a Scalar. More...
 
Scalarset (int i)
 Returns the value of a component for a tensor of valence 1 (read/write version). More...
 
Scalarset (int i1, int i2)
 Returns the value of a component for a tensor of valence 2 (read/write version). More...
 
Scalarset (int i1, int i2, int i3)
 Returns the value of a component for a tensor of valence 3 (read/write version). More...
 
Scalarset (int i1, int i2, int i3, int i4)
 Returns the value of a component for a tensor of valence 4 (read/write version). More...
 
void set_name_ind (int dd, char name)
 Sets the name of one index ; the names must have been affected first. More...
 
char const * get_name_ind () const
 
bool is_name_affected () const
 Check whether the names of the indices have been affected. More...
 
void set_name_affected ()
 Affects the name of the indices. More...
 
Tensor do_summation () const
 Does the inner contraction of the Tensor. More...
 
Tensor do_summation_one_dom (int dd) const
 Does the inner contraction of the Tensor in a given domain. More...
 
Tensor grad () const
 Computes the flat gradient, in Cartesian coordinates. More...
 
virtual void std_base ()
 Sets the standard spectal bases of decomposition for each component. More...
 
virtual int position (const Array< int > &idx) const
 Gives the location of a given component in the array used for storage (Array version). More...
 
virtual int position (const Index &idx) const
 Gives the location of a given component in the array used for storage (Index version). More...
 
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 components. More...
 
const Spaceget_space () const
 Returns the Space. More...
 
const Base_tensorget_basis () const
 Returns the vectorial basis (triad) on which the components are defined. More...
 
int get_valence () const
 Returns the valence. More...
 
int get_n_comp () const
 Returns the number of stored components. More...
 
int get_ndim () const
 Returns the number dimension. More...
 
int get_index_type (int i) const
 Gives the type (covariant or contravariant) of a given index. More...
 
Array< int > get_index_type () const
 
int & set_index_type (int i)
 Sets the type of the index number. More...
 
Array< int > & set_index_type ()
 Sets the types of all the indices. More...
 
const Scalaroperator() (const Array< int > &ind) const
 Returns the value of a component (read only version). More...
 
const Scalaroperator() (const Index &ind) const
 Returns the value of a component (read only version). More...
 
const Scalaroperator() () const
 Read only for a Scalar. More...
 
const Scalaroperator() (int i) const
 Returns the value of a component for a tensor of valence 1 (read only version). More...
 
const Scalaroperator() (int i1, int i2) const
 Returns the value of a component for a tensor of valence 2 (read only version). More...
 
const Scalarat (int i1, int i2) const
 Sylvain' stuff. More...
 
const Scalaroperator() (int i1, int i2, int i3) const
 Returns the value of a component for a tensor of valence 3 (read only version). More...
 
const Scalaroperator() (int i1, int i2, int i3, int i4) const
 Returns the value of a component for a tensor of valence 4 (read only version). More...
 
void change_basis_spher_to_cart ()
 Changes the tensorial basis from orthonormal spherical to Cartesian. More...
 
void change_basis_cart_to_spher ()
 Changes the tensorial basis from Cartesian to orthonormal spherical. More...
 
void filter (double tre)
 Sets all the coefficients below a given treshold, to zero (maintaining regularity). More...
 
void coef () const
 Computes the coefficients. More...
 
void coef_i () const
 Computes the values in the configuration space. More...
 
void operator+= (const Tensor &)
 += Tensor More...
 
void operator-= (const Tensor &)
 -= Tensor More...
 
void filter_phi (int dom, int ncf)
 Sets to zero all the coefficients above a given order, for the $ \varphi$ coefficients, in a gicen Domain. More...
 

Protected Member Functions

 Tensor (const Space &sp)
 Constructor for a scalar field: to be used only by the derived class Scalar . More...
 
 Tensor (const Space &sp, int val, const Array< int > &tipe, int n_compi, const Base_tensor &ba)
 Constructor where the number of components is prescribed. More...
 
 Tensor (const Space &sp, int val, int tipe, int n_compi, const Base_tensor &ba)
 Constructor where the number of components is prescribed (all the indices are of the same type). More...
 
 Tensor (const Space &sp, int val, const Array< int > &tipe, int n_compi, const Base_tensor &ba, int dim)
 Constructor where the number of components is prescribed. More...
 
 Tensor (const Space &sp, int val, int tipe, int n_compi, const Base_tensor &ba, int dim)
 Constructor where the number of components is prescribed (all the indices are of the same type). More...
 

Protected Attributes

const Spaceespace
 The Space. More...
 
int ndom
 The number of Domain. More...
 
int ndim
 The dimension/. More...
 
int valence
 Valence of the tensor (0 = scalar, 1 = vector, etc...) More...
 
Base_tensor basis
 Tensorial basis with respect to which the tensor components are defined. More...
 
Array< int > type_indice
 1D array of integers of size valence containing the type of each index: COV for a covariant one and CON for a contravariant one. More...
 
bool name_affected
 Indicator that states if the indices have been given names. More...
 
Memory_mapped_array< char > name_indice
 If the indices haves names they are stored here. More...
 
int n_comp
 Number of stored components, depending on the symmetry. More...
 
Memory_mapped_array< Scalar * > cmp
 Array of size n_comp of pointers onto the components. More...
 
Param_tensor parameters
 Possible additional parameters relevant for the current Tensor. More...
 
int(* give_place_array )(const Array< int > &, int)
 Pointer on the function that gives the storage location corresponding to a set of indices values. (Array version) More...
 
int(* give_place_index )(const Index &, int)
 Pointer on the function that gives the storage location corresponding to a set of indices values. (Index version) More...
 
Array< int >(* give_indices )(int, int, int)
 Pointer on the function that gives the indices corresponding to a give storage location. More...
 

Private Member Functions

bool find_indices (const Tensor &tt, Array< int > &output_ind) const
 Checks whether the current Tensor and tt have compatible indices (i.e. More...
 

Friends

class Index
 
class Domain
 
class Scalar
 
class Vector
 
class System_of_eqs
 
class Eq_matching_non_std
 
class Ope_id
 
class Metric_tensor
 
class Space_spheric_adapted
 
class Space_polar_adapted
 
class Space_bin_ns
 
class Space_bin_bh
 
class Space_polar_periodic
 
class Space_adapted_bh
 
class Space_bbh
 
class Domain_nucleus
 
class Domain_shell
 
class Domain_bispheric_chi_first
 
class Domain_bispheric_rect
 
class Domain_bispheric_eta_first
 
class Domain_shell_outer_adapted
 
class Domain_shell_inner_adapted
 
class Domain_polar_shell_outer_adapted
 
class Domain_polar_shell_inner_adapted
 
class Domain_compact
 
class Domain_polar_periodic_nucleus
 
class Domain_polar_periodic_shell
 
ostream & operator<< (ostream &, const Tensor &)
 Display. More...
 
Tensor operator+ (const Tensor &)
 Operator + (unitary version) More...
 
Tensor operator- (const Tensor &)
 Operator -. More...
 
Tensor operator+ (const Tensor &, const Tensor &)
 Operator +. More...
 
Scalar operator+ (const Tensor &, const Scalar &)
 Operator +. More...
 
Scalar operator+ (const Scalar &, const Tensor &)
 Operator +. More...
 
Tensor operator+ (const Tensor &, double)
 Operator +. More...
 
Tensor operator+ (double, const Tensor &)
 Operator +. More...
 
Tensor operator- (const Tensor &, const Tensor &)
 Operator -. More...
 
Scalar operator- (const Tensor &, const Scalar &)
 Operator -. More...
 
Scalar operator- (const Scalar &, const Tensor &)
 Operator -. More...
 
Tensor operator- (const Tensor &, double)
 Operator -. More...
 
Tensor operator- (double, const Tensor &)
 Operator -. More...
 
Tensor operator* (const Scalar &, const Tensor &)
 Operator *. More...
 
Tensor operator* (const Tensor &, const Scalar &)
 Operator *. More...
 
Tensor operator* (double, const Tensor &)
 Operator *. More...
 
Tensor operator* (const Tensor &, double)
 Operator *. More...
 
Tensor operator* (int, const Tensor &)
 Operator *. More...
 
Tensor operator* (const Tensor &, int)
 Operator *. More...
 
Tensor operator* (const Tensor &, const Tensor &)
 Tensor multiplication ; if need be contractions are performed. More...
 
Tensor operator/ (const Tensor &, const Scalar &)
 Operator /. More...
 
Tensor operator/ (const Tensor &, double)
 Operator /. More...
 
Tensor operator/ (const Tensor &, int)
 Operator /. More...
 
double maxval (const Tensor &)
 Gives the maximum value amongst all the components, at all the collocation points. More...
 
double minval (const Tensor &)
 Gives the minimum value amongst all the components, at all the collocation points. More...
 
void affecte_one_dom (int dom, Tensor *out, const Tensor *so)
 Affectation in one domain only. More...
 
Tensor add_one_dom (int, const Tensor &, const Tensor &)
 Addition (one domain version) More...
 
Tensor add_one_dom (int, const Tensor &, double)
 Addition (one domain version) More...
 
Tensor add_one_dom (int, double, const Tensor &)
 Addition (one domain version) More...
 
Tensor sub_one_dom (int, const Tensor &, const Tensor &)
 Difference (one domain version) More...
 
Tensor sub_one_dom (int, const Tensor &, double)
 Difference (one domain version) More...
 
Tensor sub_one_dom (int, double, const Tensor &)
 Difference (one domain version) More...
 
Tensor mult_one_dom (int, const Tensor &, const Tensor &)
 Multiplication (one domain version) More...
 
Tensor mult_one_dom (int, const Tensor &, double)
 Multiplication (one domain version) More...
 
Tensor mult_one_dom (int, double, const Tensor &)
 Multiplication (one domain version) More...
 
Tensor mult_one_dom (int, const Tensor &, int)
 Multiplication (one domain version) More...
 
Tensor mult_one_dom (int, int, const Tensor &)
 Multiplication (one domain version) More...
 
Tensor div_one_dom (int, const Tensor &, const Tensor &)
 Division (one domain version) More...
 
Tensor div_one_dom (int, const Tensor &, double)
 Division (one domain version) More...
 
Tensor div_one_dom (int, double, const Tensor &)
 Division (one domain version) More...
 
Tensor scal_one_dom (int, const Tensor &, const Tensor &)
 Scalar product (one domain version) More...
 
Tensor partial_one_dom (int, char, const Tensor &)
 Partial derivative (one domain version) More...
 
Tensor sqrt_one_dom (int, const Tensor &)
 Square root (one domain version) More...
 

Detailed Description

Tensor handling.

It consists mainly of an array of Scalar and some informations about the tensor (valence, type and name of indices, tensorial basis of decomposition). The indices range from 1 to ndim (the dimension) (i.e. they do NOT start from 0).

Definition at line 149 of file tensor.hpp.

Constructor & Destructor Documentation

◆ Tensor() [1/12]

Kadath::Tensor::Tensor ( const Space sp,
int  val,
const Array< int > &  tipe,
const Base_tensor ba 
)

Constructor.

Parameters
sp: the Space.
val: valence.
tipe: Array containing the types of each index (COV vs CON).
ba: the tensorial basis used.

Definition at line 77 of file tensor.cpp.

References cmp, espace, Kadath::Array< T >::get_ndim(), Kadath::Array< T >::get_size(), give_indices, give_place_array, give_place_index, n_comp, and valence.

◆ Tensor() [2/12]

Kadath::Tensor::Tensor ( const Space sp,
int  val,
int  tipe,
const Base_tensor ba 
)

Constructor where all the indices are of the same type.

Parameters
sp: the Space.
val: valence.
tipe: the type of all the indices (COV vs CON).
ba: the tensorial basis used.

Definition at line 97 of file tensor.cpp.

References cmp, espace, give_indices, give_place_array, give_place_index, n_comp, type_indice, and valence.

◆ Tensor() [3/12]

Kadath::Tensor::Tensor ( const Space sp,
int  val,
const Array< int > &  tipe,
const Base_tensor ba,
int  dim 
)

Constructor assuming the dimension of the space and the tensor is different (for dealing with symmetries)

Parameters
sp: the Space.
val: valence.
tipe: Array containing the types of each index (COV vs CON).
ba: the tensorial basis used.
dim: dimension of the tensor.

Definition at line 113 of file tensor.cpp.

References cmp, espace, Kadath::Array< T >::get_ndim(), Kadath::Array< T >::get_size(), give_indices, give_place_array, give_place_index, n_comp, and valence.

◆ Tensor() [4/12]

Kadath::Tensor::Tensor ( const Space sp,
int  val,
int  tipe,
const Base_tensor ba,
int  dim 
)

Constructor where all the indices are of the same type.

The dimension of the space and the tensor is different (for dealing with symmetries)

Parameters
sp: the Space.
val: valence.
tipe: the type of all the indices (COV vs CON).
ba: the tensorial basis used.
dim: dimension of the tensor.

Definition at line 133 of file tensor.cpp.

References cmp, espace, give_indices, give_place_array, give_place_index, n_comp, type_indice, and valence.

◆ Tensor() [5/12]

Kadath::Tensor::Tensor ( const Tensor so,
bool  copie = true 
)

Constructor by copy.

Parameters
so: the input Tensor.  
copie: if false only the property of the tensor are copied (valence etc...) not the values of the field that are left undefined.

Definition at line 153 of file tensor.cpp.

References cmp, give_indices, give_place_array, give_place_index, n_comp, name_affected, name_indice, and valence.

◆ Tensor() [6/12]

Kadath::Tensor::Tensor ( const Space sp,
FILE *  fd 
)

Constructor from a file.

Definition at line 240 of file tensor.cpp.

References cmp, espace, Kadath::Array< T >::get_size(), give_indices, give_place_array, give_place_index, n_comp, type_indice, and valence.

◆ Tensor() [7/12]

Kadath::Tensor::Tensor ( const Space sp,
int  dim,
FILE *  fd 
)

Constructor from a file with explicit passing of the dimension.

Definition at line 255 of file tensor.cpp.

References cmp, espace, Kadath::Array< T >::get_size(), give_indices, give_place_array, give_place_index, n_comp, type_indice, and valence.

◆ Tensor() [8/12]

Kadath::Tensor::Tensor ( const Space sp)
explicitprotected

Constructor for a scalar field: to be used only by the derived class Scalar .

Parameters
sp: the only parameter the Space.

Definition at line 173 of file tensor.cpp.

References cmp, give_indices, give_place_array, and give_place_index.

◆ Tensor() [9/12]

Kadath::Tensor::Tensor ( const Space sp,
int  val,
const Array< int > &  tipe,
int  n_compi,
const Base_tensor ba 
)
protected

Constructor where the number of components is prescribed.

Parameters
sp: the Space.
val: valence.
tipe: Array containing the types of each index (COV vs CON).
n_compi: number of components.
ba: the tensorial basis used.

Definition at line 196 of file tensor.cpp.

References cmp, espace, Kadath::Array< T >::get_ndim(), Kadath::Array< T >::get_size(), n_comp, and valence.

◆ Tensor() [10/12]

Kadath::Tensor::Tensor ( const Space sp,
int  val,
int  tipe,
int  n_compi,
const Base_tensor ba 
)
protected

Constructor where the number of components is prescribed (all the indices are of the same type).

Parameters
sp: the Space.
val: valence.
tipe: the type of all the indices (COV vs CON).
n_compi: number of components.
ba: the tensorial basis used.

Definition at line 185 of file tensor.cpp.

References cmp, espace, n_comp, type_indice, and valence.

◆ Tensor() [11/12]

Kadath::Tensor::Tensor ( const Space sp,
int  val,
const Array< int > &  tipe,
int  n_compi,
const Base_tensor ba,
int  dim 
)
protected

Constructor where the number of components is prescribed.

The dimension of space and the tensor can be different (to deal with symmetries)

Parameters
sp: the Space.
val: valence.
tipe: Array containing the types of each index (COV vs CON).
n_compi: number of components.
ba: the tensorial basis used.  
dim: dimension of the tensor

Definition at line 223 of file tensor.cpp.

References cmp, espace, Kadath::Array< T >::get_ndim(), Kadath::Array< T >::get_size(), n_comp, and valence.

◆ Tensor() [12/12]

Kadath::Tensor::Tensor ( const Space sp,
int  val,
int  tipe,
int  n_compi,
const Base_tensor ba,
int  dim 
)
protected

Constructor where the number of components is prescribed (all the indices are of the same type).

The dimension of space and the tensor can be different (to deal with symmetries)

Parameters
sp: the Space.
val: valence.
tipe: the type of all the indices (COV vs CON).
n_compi: number of components.
ba: the tensorial basis used.
dim: the dimension of the tensor

Definition at line 212 of file tensor.cpp.

References cmp, espace, n_comp, type_indice, and valence.

◆ ~Tensor()

Kadath::Tensor::~Tensor ( )
virtual

Destructor.

Definition at line 323 of file tensor.cpp.

References cmp.

Member Function Documentation

◆ affect_parameters()

void Kadath::Tensor::affect_parameters ( )
inline

The function affect_parameters is deprecated and actually does nothing since the parameters are now always stored in order to lower usage of the memory heap.

Definition at line 320 of file tensor.hpp.

◆ annule_hard()

void Kadath::Tensor::annule_hard ( )
inlinevirtual

Sets the Tensor to zero (hard version ; no logical state used).

Reimplemented in Kadath::Vector, and Kadath::Scalar.

Definition at line 23 of file tensor_impl.hpp.

References cmp, and n_comp.

◆ at()

const Scalar & Kadath::Tensor::at ( int  i1,
int  i2 
) const
inline

Sylvain' stuff.

Definition at line 164 of file tensor_impl.hpp.

References operator()().

◆ change_basis_cart_to_spher()

void Kadath::Tensor::change_basis_cart_to_spher ( )

◆ change_basis_spher_to_cart()

void Kadath::Tensor::change_basis_spher_to_cart ( )

◆ coef()

void Kadath::Tensor::coef ( ) const
inline

Computes the coefficients.

Definition at line 193 of file tensor_impl.hpp.

References Kadath::Index::inc().

◆ coef_i()

void Kadath::Tensor::coef_i ( ) const
inline

Computes the values in the configuration space.

Definition at line 202 of file tensor_impl.hpp.

References Kadath::Index::inc().

◆ do_summation()

Tensor Kadath::Tensor::do_summation ( ) const

Does the inner contraction of the Tensor.

It assumes exactly two indices of different types have the same name.

Returns
: the contracted Tensor (with valence -2).

Definition at line 24 of file tensor_calculus.cpp.

References basis, espace, get_n_comp(), Kadath::Space::get_nbr_domains(), Kadath::Index::inc(), name_affected, name_indice, position(), set(), Kadath::Array< T >::set(), Kadath::Base_spectral::set(), Kadath::Index::set(), Kadath::Val_domain::set_base(), Kadath::Scalar::set_domain(), type_indice, and valence.

◆ do_summation_one_dom()

Tensor Kadath::Tensor::do_summation_one_dom ( int  dd) const

Does the inner contraction of the Tensor in a given domain.

The values in the other domains are undefined. It assumes exactly two indices of different types have the same name.

Parameters
dd: the Domain where the contraction is performed.
Returns
: the contracted Tensor (with valence -2).

Definition at line 590 of file tensor_math_one_dom.cpp.

References basis, espace, get_n_comp(), Kadath::Index::inc(), name_affected, name_indice, position(), set(), Kadath::Array< T >::set(), Kadath::Val_domain::set_base(), Kadath::Scalar::set_domain(), type_indice, and valence.

◆ filter()

void Kadath::Tensor::filter ( double  tre)
inline

Sets all the coefficients below a given treshold, to zero (maintaining regularity).

Parameters
tre: the threshold.

Definition at line 221 of file tensor_impl.hpp.

References espace, Kadath::Domain::filter(), Kadath::Space::get_domain(), and Kadath::Space::get_nbr_domains().

◆ filter_phi()

void Kadath::Tensor::filter_phi ( int  dom,
int  ncf 
)
inline

Sets to zero all the coefficients above a given order, for the $ \varphi$ coefficients, in a gicen Domain.

Takes into account the various Galerkin basis to maintain regularity.

Parameters
dom: the Domain where the filter is applied.
ncf: the coefficients which index is above this are set to zero.

Definition at line 211 of file tensor_impl.hpp.

References Kadath::Scalar::filter_phi(), Kadath::Index::inc(), and set().

◆ find_indices()

bool Kadath::Tensor::find_indices ( const Tensor tt,
Array< int > &  output_ind 
) const
private

Checks whether the current Tensor and tt have compatible indices (i.e.

same names and types, possibly in a different order).

Parameters
tt: the Tensor used for the comparison.
output_ind: if the indices are compatible, it contains the permutation of the indices.
Returns
: true if the indices are compatible, false otherwise.

Definition at line 445 of file tensor.cpp.

References name_affected, name_indice, Kadath::Array< T >::set(), type_indice, and valence.

◆ get_basis()

const Base_tensor& Kadath::Tensor::get_basis ( ) const
inline

Returns the vectorial basis (triad) on which the components are defined.

Definition at line 504 of file tensor.hpp.

References basis.

◆ get_index_type() [1/2]

Array<int> Kadath::Tensor::get_index_type ( ) const
inline
Returns
The types of all the indices.

Definition at line 531 of file tensor.hpp.

References type_indice.

◆ get_index_type() [2/2]

int Kadath::Tensor::get_index_type ( int  i) const
inline

Gives the type (covariant or contravariant) of a given index.

Parameters
i: the index number (>=1)
Returns
COV for a covariant index, CON for a contravariant one.

Definition at line 526 of file tensor.hpp.

References type_indice.

◆ get_n_comp()

int Kadath::Tensor::get_n_comp ( ) const
inline

Returns the number of stored components.

Definition at line 514 of file tensor.hpp.

References n_comp.

◆ get_name_ind()

char const* Kadath::Tensor::get_name_ind ( ) const
inline
Returns
the names of all the indices.

Definition at line 424 of file tensor.hpp.

References name_indice.

◆ get_ndim()

int Kadath::Tensor::get_ndim ( ) const
inline

Returns the number dimension.

Definition at line 519 of file tensor.hpp.

References ndim.

◆ get_parameters()

const Param_tensor& Kadath::Tensor::get_parameters ( ) const
inline

Returns a pointer on the possible additional parameter.

Definition at line 311 of file tensor.hpp.

References parameters.

◆ get_space()

const Space& Kadath::Tensor::get_space ( ) const
inline

Returns the Space.

Definition at line 499 of file tensor.hpp.

References espace.

◆ get_valence()

int Kadath::Tensor::get_valence ( ) const
inline

Returns the valence.

Definition at line 509 of file tensor.hpp.

References valence.

◆ grad()

Tensor Kadath::Tensor::grad ( ) const

Computes the flat gradient, in Cartesian coordinates.

Definition at line 133 of file tensor_calculus.cpp.

References basis, Kadath::Scalar::der_abs(), espace, Kadath::Base_tensor::get_basis(), indices(), n_comp, ndim, ndom, operator()(), set(), Kadath::Array< T >::set(), type_indice, and valence.

◆ indices()

virtual Array<int> Kadath::Tensor::indices ( int  pos) const
inlinevirtual

Gives the values of the indices corresponding to a location in the array used for storage of the components.

Parameters
pos: the storage location.
Returns
: the values of all the indices.

Reimplemented in Kadath::Vector.

Definition at line 484 of file tensor.hpp.

References give_indices, ndim, and valence.

◆ is_m_order_affected()

bool Kadath::Tensor::is_m_order_affected ( ) const
inline

Checks whether the additional parameter order is affected (not very used).

Definition at line 323 of file tensor.hpp.

References Kadath::Param_tensor::m_order_affected, and parameters.

◆ is_m_quant_affected()

bool Kadath::Tensor::is_m_quant_affected ( ) const
inline

Checks whether the additional parameter $m$ is affected (used for boson stars for instance).

Definition at line 326 of file tensor.hpp.

References Kadath::Param_tensor::m_quant_affected, and parameters.

◆ is_name_affected()

bool Kadath::Tensor::is_name_affected ( ) const
inline

Check whether the names of the indices have been affected.

Definition at line 429 of file tensor.hpp.

References name_affected.

◆ operator()() [1/7]

const Scalar & Kadath::Tensor::operator() ( ) const
inline

Read only for a Scalar.

Definition at line 110 of file tensor_impl.hpp.

References cmp, and valence.

◆ operator()() [2/7]

const Scalar & Kadath::Tensor::operator() ( const Array< int > &  ind) const
inline

Returns the value of a component (read only version).

Parameters
indArray of size valence containing the values of each index specifing the component, with the following storage convention:
  • ind(0) : value of the first index
  • ind(1) : value of the second index
  • and so on...
Returns
the component specified by ind

Definition at line 169 of file tensor_impl.hpp.

References cmp, Kadath::Array< T >::get_ndim(), Kadath::Array< T >::get_size(), position(), and valence.

◆ operator()() [3/7]

const Scalar & Kadath::Tensor::operator() ( const Index ind) const
inline

Returns the value of a component (read only version).

Parameters
indIndex of size valence containing the values of each index specifing the component, with the following storage convention:
  • ind(0) : value of the first index
  • ind(1) : value of the second index
  • and so on...
Returns
the component specified by ind

Definition at line 177 of file tensor_impl.hpp.

References operator()(), Kadath::Array< T >::set(), and valence.

◆ operator()() [4/7]

const Scalar & Kadath::Tensor::operator() ( int  i) const
inline

Returns the value of a component for a tensor of valence 1 (read only version).

Parameters
ivalue of the first index
Returns
the component specified by (i1)

Definition at line 118 of file tensor_impl.hpp.

References cmp, position(), Kadath::Array< T >::set(), and valence.

◆ operator()() [5/7]

const Scalar & Kadath::Tensor::operator() ( int  i1,
int  i2 
) const
inline

Returns the value of a component for a tensor of valence 2 (read only version).

Parameters
i1value of the first index
i2value of the second index
Returns
the component specified by (i1,i2)

Definition at line 128 of file tensor_impl.hpp.

References cmp, position(), Kadath::Array< T >::set(), and valence.

◆ operator()() [6/7]

const Scalar & Kadath::Tensor::operator() ( int  i1,
int  i2,
int  i3 
) const
inline

Returns the value of a component for a tensor of valence 3 (read only version).

Parameters
i1value of the first index
i2value of the second index
i3value of the third index
Returns
the component specified by (i1,i2,i3)

Definition at line 139 of file tensor_impl.hpp.

References cmp, position(), Kadath::Array< T >::set(), and valence.

◆ operator()() [7/7]

const Scalar & Kadath::Tensor::operator() ( int  i1,
int  i2,
int  i3,
int  i4 
) const
inline

Returns the value of a component for a tensor of valence 4 (read only version).

Parameters
i1value of the first index
i2value of the second index
i3value of the third index
i4value of the fourth index
Returns
the component specified by (i1,i2,i3,i4)

Definition at line 151 of file tensor_impl.hpp.

References cmp, position(), Kadath::Array< T >::set(), and valence.

◆ operator+=()

void Kadath::Tensor::operator+= ( const Tensor t)

◆ operator-=()

void Kadath::Tensor::operator-= ( const Tensor t)

◆ operator=() [1/2]

Tensor & Kadath::Tensor::operator= ( const Tensor t)
virtual

◆ operator=() [2/2]

Tensor & Kadath::Tensor::operator= ( double  xx)
virtual

Assignment to a double (the same value for all the components at all the collocation points).

Reimplemented in Kadath::Vector, Kadath::Scalar, and Kadath::Metric_tensor.

Definition at line 64 of file tensor_math.cpp.

References cmp, and n_comp.

◆ position() [1/2]

virtual int Kadath::Tensor::position ( const Array< int > &  idx) const
inlinevirtual

Gives the location of a given component in the array used for storage (Array version).

Parameters
idx: values of the indices.
Returns
: the storage location.

Reimplemented in Kadath::Vector.

Definition at line 470 of file tensor.hpp.

References give_place_array, and ndim.

◆ position() [2/2]

virtual int Kadath::Tensor::position ( const Index idx) const
inlinevirtual

Gives the location of a given component in the array used for storage (Index version).

Parameters
idx: values of the indices.
Returns
: the storage location.

Reimplemented in Kadath::Vector.

Definition at line 477 of file tensor.hpp.

References give_place_index, and ndim.

◆ save()

void Kadath::Tensor::save ( FILE *  fd) const
virtual

Saving operator.

Reimplemented in Kadath::Scalar.

Definition at line 327 of file tensor.cpp.

References basis, cmp, Kadath::Array< T >::get_size(), n_comp, Kadath::Base_tensor::save(), Kadath::Array< T >::save(), type_indice, and valence.

◆ set() [1/7]

Scalar& Kadath::Tensor::set ( )
inline

Read/write for a Scalar.

Definition at line 364 of file tensor.hpp.

References cmp, and valence.

◆ set() [2/7]

Scalar & Kadath::Tensor::set ( const Array< int > &  ind)
inline

Returns the value of a component (read/write version).

Parameters
indArray of size valence containing the values of each index specifing the component, with the following storage convention:
  • ind(0) : value of the first index
  • ind(1) : value of the second index
  • and so on...
Returns
modifiable reference on the component specified by ind

Definition at line 91 of file tensor_impl.hpp.

References cmp, Kadath::Array< T >::get_ndim(), Kadath::Array< T >::get_size(), position(), and valence.

◆ set() [3/7]

Scalar & Kadath::Tensor::set ( const Index ind)
inline

Returns the value of a component (read/write version).

Parameters
ind1-D Index of size valence containing the values of each index specifing the component, with the following storage convention:
  • ind(0) : value of the first index
  • ind(1) : value of the second index
  • and so on...
Returns
modifiable reference on the component specified by ind

Definition at line 101 of file tensor_impl.hpp.

References set(), Kadath::Array< T >::set(), and valence.

◆ set() [4/7]

Scalar & Kadath::Tensor::set ( int  i)
inline

Returns the value of a component for a tensor of valence 1 (read/write version).

Parameters
ivalue of the first index
Returns
modifiable reference on the component specified by (i1)

Definition at line 33 of file tensor_impl.hpp.

References cmp, position(), Kadath::Array< T >::set(), and valence.

◆ set() [5/7]

Scalar & Kadath::Tensor::set ( int  i1,
int  i2 
)
inline

Returns the value of a component for a tensor of valence 2 (read/write version).

Parameters
i1value of the first index
i2value of the second index
Returns
modifiable reference on the component specified by (i1,i2)

Definition at line 46 of file tensor_impl.hpp.

References cmp, position(), Kadath::Array< T >::set(), and valence.

◆ set() [6/7]

Scalar & Kadath::Tensor::set ( int  i1,
int  i2,
int  i3 
)
inline

Returns the value of a component for a tensor of valence 3 (read/write version).

Parameters
i1value of the first index
i2value of the second index
i3value of the third index
Returns
modifiable reference on the component specified by (i1,i2,i3)

Definition at line 60 of file tensor_impl.hpp.

References cmp, position(), Kadath::Array< T >::set(), and valence.

◆ set() [7/7]

Scalar & Kadath::Tensor::set ( int  i1,
int  i2,
int  i3,
int  i4 
)
inline

Returns the value of a component for a tensor of valence 4 (read/write version).

Parameters
i1value of the first index
i2value of the second index
i3value of the third index
i4value of the fourth index
Returns
modifiable reference on the component specified by (i1,i2,i3,i4)

Definition at line 75 of file tensor_impl.hpp.

References cmp, position(), Kadath::Array< T >::set(), and valence.

◆ set_basis()

int& Kadath::Tensor::set_basis ( int  dd)
inline

Assigns a new tensorial basis in a given domain.

Parameters
dd: the index of the Domain.

Definition at line 331 of file tensor.hpp.

References basis, and Kadath::Base_tensor::set_basis().

◆ set_index_type() [1/2]

Array<int>& Kadath::Tensor::set_index_type ( )
inline

Sets the types of all the indices.

Returns
a reference on an array describing the types of all the indices (CON or COV).

Definition at line 545 of file tensor.hpp.

References type_indice.

◆ set_index_type() [2/2]

int& Kadath::Tensor::set_index_type ( int  i)
inline

Sets the type of the index number.

Parameters
i: the index number (>=1)
Returns
set to COV or CON.

Definition at line 538 of file tensor.hpp.

References Kadath::Array< T >::set(), and type_indice.

◆ set_name_affected()

void Kadath::Tensor::set_name_affected ( )
inline

Affects the name of the indices.

They have to be given values afterwards.

Definition at line 435 of file tensor.hpp.

References name_affected.

◆ set_name_ind()

void Kadath::Tensor::set_name_ind ( int  dd,
char  name 
)
inline

Sets the name of one index ; the names must have been affected first.

Parameters
dd: which index ?
name: the name.

Definition at line 186 of file tensor_impl.hpp.

References name_affected, name_indice, and valence.

◆ set_parameters()

Param_tensor& Kadath::Tensor::set_parameters ( )
inline

Read/write of the parameters.

Definition at line 314 of file tensor.hpp.

References parameters.

◆ std_base()

void Kadath::Tensor::std_base ( )
virtual

Sets the standard spectal bases of decomposition for each component.

To be used only with valence lower than or equal 2.

Reimplemented in Kadath::Scalar.

Definition at line 385 of file tensor.cpp.

References basis, cmp, espace, Kadath::Base_tensor::get_basis(), Kadath::Space::get_domain(), Kadath::Param_tensor::get_m_quant(), indices(), is_m_quant_affected(), Kadath::Domain::mult(), n_comp, ndom, parameters, std_base(), and valence.

◆ swap()

void Kadath::Tensor::swap ( Tensor so)
noexcept

Swap method.

Definition at line 270 of file tensor.cpp.

Friends And Related Function Documentation

◆ add_one_dom [1/3]

Tensor add_one_dom ( int  dd,
const Tensor t1,
const Tensor t2 
)
friend

Addition (one domain version)

Definition at line 55 of file tensor_math_one_dom.cpp.

◆ add_one_dom [2/3]

Tensor add_one_dom ( int  dd,
const Tensor t,
double  xx 
)
friend

Addition (one domain version)

Definition at line 126 of file tensor_math_one_dom.cpp.

◆ add_one_dom [3/3]

Tensor add_one_dom ( int  dd,
double  xx,
const Tensor t 
)
friend

Addition (one domain version)

Definition at line 140 of file tensor_math_one_dom.cpp.

◆ affecte_one_dom

void affecte_one_dom ( int  dom,
Tensor out,
const Tensor so 
)
friend

Affectation in one domain only.

Parameters
dom[input] : the domain index.
out[output] : pointer on the result
so[input] : pointer on the input Tensor

Definition at line 24 of file tensor_math_one_dom.cpp.

◆ div_one_dom [1/3]

Tensor div_one_dom ( int  dd,
const Tensor t1,
const Tensor t2 
)
friend

Division (one domain version)

Definition at line 512 of file tensor_math_one_dom.cpp.

◆ div_one_dom [2/3]

Tensor div_one_dom ( int  dd,
const Tensor t,
double  xx 
)
friend

Division (one domain version)

Definition at line 555 of file tensor_math_one_dom.cpp.

◆ div_one_dom [3/3]

Tensor div_one_dom ( int  dd,
double  x,
const Tensor t 
)
friend

Division (one domain version)

Definition at line 538 of file tensor_math_one_dom.cpp.

◆ maxval

double maxval ( const Tensor target)
friend

Gives the maximum value amongst all the components, at all the collocation points.

Definition at line 548 of file tensor_math.cpp.

◆ minval

double minval ( const Tensor target)
friend

Gives the minimum value amongst all the components, at all the collocation points.

Definition at line 580 of file tensor_math.cpp.

◆ mult_one_dom [1/5]

Tensor mult_one_dom ( int  dd,
const Tensor t1,
const Tensor t2 
)
friend

Multiplication (one domain version)

Definition at line 249 of file tensor_math_one_dom.cpp.

◆ mult_one_dom [2/5]

Tensor mult_one_dom ( int  dd,
const Tensor t,
double  xx 
)
friend

Multiplication (one domain version)

Definition at line 444 of file tensor_math_one_dom.cpp.

◆ mult_one_dom [3/5]

Tensor mult_one_dom ( int  dd,
const Tensor t,
int  mm 
)
friend

Multiplication (one domain version)

Definition at line 478 of file tensor_math_one_dom.cpp.

◆ mult_one_dom [4/5]

Tensor mult_one_dom ( int  dd,
double  xx,
const Tensor t 
)
friend

Multiplication (one domain version)

Definition at line 461 of file tensor_math_one_dom.cpp.

◆ mult_one_dom [5/5]

Tensor mult_one_dom ( int  dd,
int  mm,
const Tensor t 
)
friend

Multiplication (one domain version)

Definition at line 495 of file tensor_math_one_dom.cpp.

◆ operator* [1/7]

Tensor operator* ( const Scalar t1,
const Tensor t2 
)
friend

Operator *.

Definition at line 263 of file tensor_math.cpp.

◆ operator* [2/7]

Tensor operator* ( const Tensor t2,
const Scalar t1 
)
friend

Operator *.

Definition at line 275 of file tensor_math.cpp.

◆ operator* [3/7]

Tensor operator* ( const Tensor t1,
const Tensor t2 
)
friend

Tensor multiplication ; if need be contractions are performed.

Definition at line 316 of file tensor_math.cpp.

◆ operator* [4/7]

Tensor operator* ( const Tensor t,
double  x 
)
friend

Operator *.

Definition at line 295 of file tensor_math.cpp.

◆ operator* [5/7]

Tensor operator* ( const Tensor t,
int  m 
)
friend

Operator *.

Definition at line 311 of file tensor_math.cpp.

◆ operator* [6/7]

Tensor operator* ( double  x,
const Tensor t 
)
friend

Operator *.

Definition at line 281 of file tensor_math.cpp.

◆ operator* [7/7]

Tensor operator* ( int  m,
const Tensor t 
)
friend

Operator *.

Definition at line 299 of file tensor_math.cpp.

◆ operator+ [1/6]

Scalar operator+ ( const Scalar t1,
const Tensor t2 
)
friend

Operator +.

Definition at line 187 of file tensor_math.cpp.

◆ operator+ [2/6]

Tensor operator+ ( const Tensor t)
friend

Operator + (unitary version)

Definition at line 144 of file tensor_math.cpp.

◆ operator+ [3/6]

Scalar operator+ ( const Tensor t1,
const Scalar t2 
)
friend

Operator +.

Definition at line 180 of file tensor_math.cpp.

◆ operator+ [4/6]

Tensor operator+ ( const Tensor t1,
const Tensor t2 
)
friend

Operator +.

Definition at line 172 of file tensor_math.cpp.

◆ operator+ [5/6]

Tensor operator+ ( const Tensor t,
double  xx 
)
friend

Operator +.

Definition at line 194 of file tensor_math.cpp.

◆ operator+ [6/6]

Tensor operator+ ( double  xx,
const Tensor t 
)
friend

Operator +.

Definition at line 203 of file tensor_math.cpp.

◆ operator- [1/6]

Scalar operator- ( const Scalar t1,
const Tensor t2 
)
friend

Operator -.

Definition at line 231 of file tensor_math.cpp.

◆ operator- [2/6]

Tensor operator- ( const Tensor t)
friend

Operator -.

Definition at line 150 of file tensor_math.cpp.

◆ operator- [3/6]

Scalar operator- ( const Tensor t1,
const Scalar t2 
)
friend

Operator -.

Definition at line 224 of file tensor_math.cpp.

◆ operator- [4/6]

Tensor operator- ( const Tensor t1,
const Tensor t2 
)
friend

Operator -.

Definition at line 217 of file tensor_math.cpp.

◆ operator- [5/6]

Tensor operator- ( const Tensor t,
double  xx 
)
friend

Operator -.

Definition at line 239 of file tensor_math.cpp.

◆ operator- [6/6]

Tensor operator- ( double  xx,
const Tensor t 
)
friend

Operator -.

Definition at line 248 of file tensor_math.cpp.

◆ operator/ [1/3]

Tensor operator/ ( const Tensor t1,
const Scalar s2 
)
friend

Operator /.

Definition at line 506 of file tensor_math.cpp.

◆ operator/ [2/3]

Tensor operator/ ( const Tensor t,
double  x 
)
friend

Operator /.

Definition at line 521 of file tensor_math.cpp.

◆ operator/ [3/3]

Tensor operator/ ( const Tensor t,
int  m 
)
friend

Operator /.

Definition at line 541 of file tensor_math.cpp.

◆ operator<<

ostream& operator<< ( ostream &  flux,
const Tensor source 
)
friend

Display.

Definition at line 339 of file tensor.cpp.

◆ partial_one_dom

Tensor partial_one_dom ( int  dd,
char  ind_partial,
const Tensor so 
)
friend

Partial derivative (one domain version)

Definition at line 703 of file tensor_math_one_dom.cpp.

◆ scal_one_dom

Tensor scal_one_dom ( int  dd,
const Tensor t1,
const Tensor t2 
)
friend

Scalar product (one domain version)

Definition at line 573 of file tensor_math_one_dom.cpp.

◆ sqrt_one_dom

Tensor sqrt_one_dom ( int  dd,
const Tensor t 
)
friend

Square root (one domain version)

Definition at line 747 of file tensor_math_one_dom.cpp.

◆ sub_one_dom [1/3]

Tensor sub_one_dom ( int  dd,
const Tensor t1,
const Tensor t2 
)
friend

Difference (one domain version)

Definition at line 154 of file tensor_math_one_dom.cpp.

◆ sub_one_dom [2/3]

Tensor sub_one_dom ( int  dd,
const Tensor t,
double  xx 
)
friend

Difference (one domain version)

Definition at line 224 of file tensor_math_one_dom.cpp.

◆ sub_one_dom [3/3]

Tensor sub_one_dom ( int  dd,
double  xx,
const Tensor t 
)
friend

Difference (one domain version)

Definition at line 237 of file tensor_math_one_dom.cpp.

Member Data Documentation

◆ basis

Base_tensor Kadath::Tensor::basis
protected

Tensorial basis with respect to which the tensor components are defined.

Definition at line 163 of file tensor.hpp.

◆ cmp

Memory_mapped_array<Scalar *> Kadath::Tensor::cmp
protected

Array of size n_comp of pointers onto the components.

Definition at line 179 of file tensor.hpp.

◆ espace

const Space& Kadath::Tensor::espace
protected

The Space.

Definition at line 154 of file tensor.hpp.

◆ give_indices

Array<int>(* Kadath::Tensor::give_indices) (int, int, int)
protected

Pointer on the function that gives the indices corresponding to a give storage location.

Definition at line 185 of file tensor.hpp.

◆ give_place_array

int(* Kadath::Tensor::give_place_array) (const Array< int > &, int)
protected

Pointer on the function that gives the storage location corresponding to a set of indices values. (Array version)

Definition at line 184 of file tensor.hpp.

◆ give_place_index

int(* Kadath::Tensor::give_place_index) (const Index &, int)
protected

Pointer on the function that gives the storage location corresponding to a set of indices values. (Index version)

Definition at line 185 of file tensor.hpp.

◆ n_comp

int Kadath::Tensor::n_comp
protected

Number of stored components, depending on the symmetry.

Definition at line 178 of file tensor.hpp.

◆ name_affected

bool Kadath::Tensor::name_affected
protected

Indicator that states if the indices have been given names.

Definition at line 172 of file tensor.hpp.

◆ name_indice

Memory_mapped_array<char> Kadath::Tensor::name_indice
protected

If the indices haves names they are stored here.

Each index is associated with a character.

Definition at line 176 of file tensor.hpp.

◆ ndim

int Kadath::Tensor::ndim
protected

The dimension/.

Definition at line 156 of file tensor.hpp.

◆ ndom

int Kadath::Tensor::ndom
protected

The number of Domain.

Definition at line 155 of file tensor.hpp.

◆ parameters

Param_tensor Kadath::Tensor::parameters
protected

Possible additional parameters relevant for the current Tensor.

Definition at line 181 of file tensor.hpp.

◆ type_indice

Array<int> Kadath::Tensor::type_indice
protected

1D array of integers of size valence containing the type of each index: COV for a covariant one and CON for a contravariant one.

Definition at line 170 of file tensor.hpp.

◆ valence

int Kadath::Tensor::valence
protected

Valence of the tensor (0 = scalar, 1 = vector, etc...)

Definition at line 157 of file tensor.hpp.


The documentation for this class was generated from the following files: