21 #include "tensor_impl.hpp"
22 #include "metric_tensor.hpp"
24 double sign(gsl_permutation* p)
26 int card(
static_cast<int>(gsl_permutation_size(p)));
27 double signature(1.0);
28 for (
int i(0 ); i < card - 1 ; ++i)
29 for (
int j(i+1) ; j < card ; ++j)
31 double pj(
static_cast<double>(gsl_permutation_get(p, j)));
32 double pi(
static_cast<double>(gsl_permutation_get(p, i)));
33 signature *= (pj - pi) / (j - i);
38 vector<int> ind_com(
int i,
int j,
int k,
int l)
56 if (k >= j and l >= i)
64 int metric_tensor_position_array (
const Array<int>& idx,
int ndim) {
66 assert (idx.get_ndim() == 1) ;
67 assert (idx.get_size(0) == 2) ;
69 for (
int i=0 ; i<2 ; i++)
70 assert ((idx(i)>=1) && (idx(i)<=ndim)) ;
76 for (
int i=0 ; i<ndim ; i++)
77 for (
int j=i ; j<ndim ; j++) {
78 if ((i+1==idx(0)) && (j+1==idx(1)))
85 for (
int i=0 ; i<ndim ; i++)
86 for (
int j=i ; j<ndim ; j++) {
87 if ((i+1==idx(1)) && (j+1==idx(0)))
96 int metric_tensor_position_index (
const Index& idx,
int ndim) {
97 assert (idx.get_ndim() == 2) ;
98 for (
int i=0 ; i<2 ; i++)
99 assert ((idx(i)>=0) && (idx(i)<ndim)) ;
105 for (
int i=0 ; i<ndim ; i++)
106 for (
int j=i ; j<ndim ; j++) {
107 if ((i==idx(0)) && (j==idx(1)))
114 for (
int i=0 ; i<ndim ; i++)
115 for (
int j=i ; j<ndim ; j++) {
116 if ((i==idx(1)) && (j==idx(0)))
125 Array<int> metric_tensor_indices (
int pos,
int valence,
int ndim) {
127 assert (valence==2) ;
128 Array<int> res (valence) ;
130 for (
int i=1 ; i<=ndim ; i++)
131 for (
int j=i ; j<=ndim ; j++) {
152 for (
int i=0 ; i<
n_comp ; i++)
165 for (
int i=1 ; i<=
ndim ; i++)
166 for (
int j=i ; j<=
ndim ; j++)
167 set(i,j) = (so(i,j) + so(j,i))/2. ;
172 for (
int i=0 ; i<
n_comp ; i++)
188 gsl_permutation* p(gsl_permutation_calloc(dim));
191 int p1(
static_cast<int>(gsl_permutation_get(p, 0)) + 1);
192 int p2(
static_cast<int>(gsl_permutation_get(p, 1)) + 1);
193 int p3(
static_cast<int>(gsl_permutation_get(p, 2)) + 1);
194 detval += sign(p)*res(p1, 1)(d)*res(p2, 2)(d)*res(p3, 3)(d);
195 }
while(gsl_permutation_next(p) == GSL_SUCCESS);
196 gsl_permutation_free(p);
200 for (
int i(1) ; i <= dim ; ++i)
202 for (
int j(i) ; j <= dim ; ++j)
205 p = gsl_permutation_calloc(dim - 1);
208 int p1(
static_cast<int>(gsl_permutation_get(p, 0)) + 1);
209 int p2(
static_cast<int>(gsl_permutation_get(p, 1)) + 1);
210 vector<int> index1, index2;
211 index1 = ind_com(i, j, p1, 1);
212 index2 = ind_com(i, j, p2, 2);
213 cmpval += pow(-1.0, i + j)*sign(p)*(*this)(index1[0], index1[1])(d)*(*this)(index2[0],index2[1])(d);
214 }
while(gsl_permutation_next(p) == GSL_SUCCESS);
215 gsl_permutation_free(p);
225 for (
int d(0) ; d <
ndom ; ++d)
227 cmp[0]->std_base_domain(d);
228 cmp[3]->std_base_domain(d);
229 cmp[5]->std_base_domain(d);
232 cmp[1]->std_base_xy_cart_domain(d);
233 cmp[2]->std_base_xz_cart_domain(d);
234 cmp[4]->std_base_yz_cart_domain(d);
238 cmp[1]->std_base_rt_spher_domain(d);
239 cmp[2]->std_base_rp_spher_domain(d);
240 cmp[4]->std_base_tp_spher_domain(d);
int get_basis(int nd) const
Read only the basis in a given domain.
Particular type of Tensor, dedicated to the desription of metrics.
Metric_tensor & operator=(const Metric_tensor &)
Assignment to another Metric_tensor.
void std_base2()
Specialized base setting (for AADS)
Metric_tensor inverse()
Computes the inverse of the current objetc.
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.
int get_ndim() const
Returns the number of dimensions.
int get_nbr_domains() const
Returns the number of Domains.
Base_tensor basis
Tensorial basis with respect to which the tensor components are defined.
int ndom
The number of Domain.
int valence
Valence of the tensor (0 = scalar, 1 = vector, etc...)
Array< int > type_indice
1D array of integers of size valence containing the type of each index: COV for a covariant one and C...
Memory_mapped_array< Scalar * > cmp
Array of size n_comp of pointers onto the components.
Array< int > get_index_type() const
Scalar & set(const Array< int > &ind)
Returns the value of a component (read/write version).
int & set_index_type(int i)
Sets the type of the index number.
Scalar & set()
Read/write for a Scalar.
int n_comp
Number of stored components, depending on the symmetry.
const Space & espace
The Space.
Class for storing the basis of decompositions of a field and its values on both the configuration and...