Peano 4
Loading...
Searching...
No Matches
Vector.h
Go to the documentation of this file.
1// This file is part of the Peano project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3#pragma once
4
5#include "tarch/la/la.h"
6#include "tarch/Assertions.h"
9
10#include <string>
11#include <bitset>
12#include <sstream>
13#include <initializer_list>
14
15namespace tarch {
16 namespace la {
17 template <int Size, typename Scalar>
18 struct Vector;
19
20 template <typename NewScalarType, int Size, typename Scalar>
22 }
23}
24
30template<int Size, typename Scalar>
31std::string toString( const tarch::la::Vector<Size,Scalar>& vector );
32
133template <int Size, typename Scalar>
135 private:
136 Scalar _values[Size];
137
138 public:
142 Vector() InlineMethod = default;
143
144 Vector( const Scalar* values ) InlineMethod;
145
153 Vector( std::initializer_list<Scalar> values );
154
155 Vector( const std::bitset<Size>& values ) InlineMethod;
156
160 Vector(const Scalar& initialValue);
161
170 inline Vector<Size,Scalar>& operator= (const Vector<Size,Scalar>& toAssign) InlineMethod;
171
180 Vector(const Vector<Size,Scalar>& toCopy);
181
185 int size() const;
186
196 inline const Scalar& operator[] (int index) const InlineMethod {
197#if defined(GPUOffloadingOff)
198 assertion3 ( index >= 0, index, Size, ::toString(*this) );
199 assertion4 ( index < Size, index, Size, ::toString(*this), "you may not take the indexth entry from a vector with only Size components" );
200#endif
201 return _values[index];
202 }
203
209 inline Scalar& operator[] (int index) InlineMethod {
210#if defined(GPUOffloadingOff)
211 assertion3 ( index >= 0, index, Size, ::toString(*this) );
212 assertion3 ( index < Size, index, Size, ::toString(*this) );
213#endif
214 return _values[index];
215 }
216
228 inline const Scalar& operator() (int index) const InlineMethod {
229#if defined(GPUOffloadingOff)
230 assertion3 ( index >= 0, index, Size, ::toString(*this) );
231 assertion3 ( index < Size, index, Size, ::toString(*this) );
232#endif
233 return _values[index];
234 }
235
241 inline Scalar& operator() (int index) InlineMethod {
242#if defined(GPUOffloadingOff)
243 assertion3 ( index >= 0, index, Size, ::toString(*this) );
244 assertion3 ( index < Size, index, Size, ::toString(*this) );
245#endif
246 return _values[index];
247 }
248
254 Scalar* data() {
255 return _values;
256 }
257
258 const Scalar * data() const {
259 return _values;
260 }
261};
262
263#include "tarch/la/Vector.cpph"
267#include "tarch/la/VectorSlice.h"
268
#define assertion4(expr, param0, param1, param2, param3)
#define assertion3(expr, param0, param1, param2)
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
std::string toString(const tarch::la::Vector< Size, Scalar > &vector)
Pipes the elements of a vector into a std::string and returns the string.
Definition Vector.cpph:80
STL namespace.
tarch::la::Vector< Size, NewScalarType > convertScalar(const tarch::la::Vector< Size, Scalar > &vector)
Definition Vector.cpph:94
Have to include this header, as I need access to the SYCL_EXTERNAL keyword.
Definition accelerator.h:17
std::string toString(MemoryLocation value)
Simple vector class.
Definition Vector.h:134
const Scalar * data() const
Definition Vector.h:258
const Scalar & operator()(int index) const InlineMethod
Returns read-only ref.
Definition Vector.h:228
Scalar * data()
This routine returns a pointer to the first data element.
Definition Vector.h:254
Scalar _values[Size]
Definition Vector.h:136
const Scalar & operator[](int index) const InlineMethod
Returns read-only ref.
Definition Vector.h:196
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
#define InlineMethod
This is the marker that is to be used after the argument list of a function declaration.
Definition tarch.h:58