KADATH
vector.cpp
1 /*
2  Copyright 2017 Philippe Grandclement
3 
4  This file is part of Kadath.
5 
6  Kadath is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Kadath is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Kadath. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "vector.hpp"
21 #include "tensor.hpp"
22 #include "scalar.hpp"
23 #include "tensor_impl.hpp"
24 namespace Kadath {
26  assert (&espace==&t.espace) ;
27  basis = t.basis ;
28  assert(t.type_indice(0) == type_indice(0)) ;
29 
30  for (int i=0 ; i<3 ; i++) {
31  *cmp[i] = *t.cmp[i] ;
32  }
33  return *this;
34  }
35 
37 
38  assert (t.valence == 1) ;
39 
40 
41  assert (&espace==&t.espace) ;
42  basis = t.basis ;
43  assert(t.type_indice(0) == type_indice(0)) ;
44 
45  for (int i=0 ; i<3 ; i++) {
46  *cmp[i] = *t.cmp[i] ;
47  }
48  return *this;
49  }
50 
51  Vector & Vector::operator=(double xx) {
52  for (int i=0 ; i<3 ; i++) {
53  *cmp[i] = xx ;
54  }
55  return *this;
56  }
57 
58 }
Tensor handling.
Definition: tensor.hpp:149
Base_tensor basis
Tensorial basis with respect to which the tensor components are defined.
Definition: tensor.hpp:163
int valence
Valence of the tensor (0 = scalar, 1 = vector, etc...)
Definition: tensor.hpp:157
Array< int > type_indice
1D array of integers of size valence containing the type of each index: COV for a covariant one and C...
Definition: tensor.hpp:170
Memory_mapped_array< Scalar * > cmp
Array of size n_comp of pointers onto the components.
Definition: tensor.hpp:179
const Space & espace
The Space.
Definition: tensor.hpp:154
A class derived from Tensor to deal specificaly with objects of valence 1 (and so also 1-forms).
Definition: vector.hpp:41
Vector & operator=(const Vector &)
Assignment to another Vector.
Definition: vector.cpp:25