Peano 4
Loading...
Searching...
No Matches
Vector.cpph
Go to the documentation of this file.
1template<int Size, typename Scalar>
3 for (int i=0; i<Size; i++) {
4 _values[i] = *(values+i);
5 }
6}
7
13template<int Size, typename Scalar>
14tarch::la::Vector<Size,Scalar>::Vector(std::initializer_list<Scalar> values) {
15 int index = 0;
16 for (typename std::initializer_list<Scalar>::const_iterator p = values.begin(); p!=values.end(); p++) {
17 _values[index] = *p;
18 index++;
19 }
20}
21
22
23template<int Size, typename Scalar>
24tarch::la::Vector<Size,Scalar>::Vector( const std::bitset<Size>& value ) {
25 for (int i=0; i<Size; i++) {
26 _values[i] = value[i] ? 1 : 0;
27 }
28}
29
30template<int Size, typename Scalar>
32 const Vector<Size,Scalar>& toAssign
33) {
34 #if !defined(GPUOffloadingOMP) and !defined(GPUOffloadingSYCL) and !defined(SharedSYCL)
35 assertion(this != &toAssign);
36 #endif
37
38 #ifdef CompilerICC
39 #pragma ivdep
40 #endif
41 for (int i=0; i<Size; i++) {
42 _values[i] = toAssign._values[i];
43 }
44 return *this;
45}
46
47template<int Size, typename Scalar>
49 const Vector<Size,Scalar>& toCopy
50):
51 _values() {
52 #if !defined(GPUOffloadingOMP) and !defined(GPUOffloadingSYCL) and !defined(SharedSYCL)
53 assertion(this != &toCopy);
54 #endif
55
56 #ifdef CompilerICC
57 #pragma ivdep
58 #endif
59 for (int i=0; i<Size; i++) {
60 _values[i] = toCopy._values[i];
61 }
62}
63
64template<int Size, typename Scalar>
66 const Scalar& initialValue
67):
68 _values() {
69 for (int i=0; i < Size; i++) {
70 _values[i] = initialValue;
71 }
72}
73
74template<int Size, typename Scalar>
76 return Size;
77}
78
79template<int Size, typename Scalar>
80std::string toString( const tarch::la::Vector<Size,Scalar>& vector ) {
81 std::ostringstream os;
82 os << "[";
83 for ( int i=0; i < Size; i++ ) {
84 os << vector(i);
85 if ( i + 1 < Size ) {
86 os << ",";
87 }
88 }
89 os << "]";
90 return os.str();
91}
92
93template <typename NewScalarType, int Size, typename Scalar>
96 for ( int i=0; i < Size; i++ ) {
97 result(i) = vector(i);
98 }
99 return result;
100}
#define assertion(expr)
And from this we can write down f$ nabla phi_i nabla phi_i dx but since we are constructing matrix let s investigate the f$ our matrix elements will nabla phi_i dx f By this will be a sparse as these basis functions are chosen to not overlap with each other almost everywhere In other they have only local support We can read off the right hand side values
tarch::la::Vector< Size, NewScalarType > convertScalar(const tarch::la::Vector< Size, Scalar > &vector)
Definition Vector.cpph:94
std::string toString(MemoryLocation value)
Simple vector class.
Definition Vector.h:134
Vector< Size, Scalar > & operator=(const Vector< Size, Scalar > &toAssign) InlineMethod
Assignment operator for any vector type.
Definition Vector.cpph:31
Scalar _values[Size]
Definition Vector.h:136
Vector() InlineMethod=default
Clang requires the always_inline attribute, as it otherwise makes weird decisions.
int size() const
Returns the number of components of the vector.
Definition Vector.cpph:75