15#include <initializer_list>
39 template<
class K,
int SIZE >
class FieldVector;
40 template<
class K,
int SIZE >
46 typedef typename container_type::size_type
size_type;
49 template<
class K,
int SIZE >
64 template<
typename C,
int SIZE>
71 constexpr static bool value =
true;
74 template<
typename T,
int SIZE>
77 constexpr static bool value =
true;
80 template<
typename T,
int SIZE,
int SIZE1>
83 constexpr static bool value =
false;
92 template<
class K,
int SIZE >
96 std::array<K,SIZE> _data;
119 std::fill(_data.begin(),_data.end(),t);
122#if __GNUC__ == 5 && !defined(__clang__)
134 assert(l.size() == dimension);
135 std::copy_n(l.begin(), std::min(
static_cast<std::size_t
>(dimension),
143 template <
typename T>
146 std::copy_n(x.
begin(), SIZE, _data.begin());
150 template<
typename T,
int N>
169 assert(x.
size() == SIZE);
170 std::copy_n(x.
begin(), std::min(
static_cast<std::size_t
>(SIZE),x.
size()), _data.begin());
177 std::copy_n(x.
begin(), SIZE, _data.begin());
180 template<
typename T,
int N>
183 using Base::operator=;
210 template <
class Scalar,
211 std::enable_if_t<IsNumber<Scalar>::value,
int> = 0>
217 result[i] = vector[i] * scalar;
223 template <
class Scalar,
224 std::enable_if_t<IsNumber<Scalar>::value,
int> = 0>
230 result[i] = scalar * vector[i];
236 template <
class Scalar,
237 std::enable_if_t<IsNumber<Scalar>::value,
int> = 0>
243 result[i] = vector[i] / scalar;
261 template<
class K,
int SIZE>
262 inline std::istream &operator>> ( std::istream &in,
278 typedef K container_type;
279 typedef K value_type;
280 typedef size_t size_type;
286 class FieldVector<K, 1> :
287 public DenseVector< FieldVector<K,1> >
290 typedef DenseVector< FieldVector<K,1> > Base;
293 constexpr static int dimension = 1;
295 typedef typename Base::size_type size_type;
298 typedef K& reference;
301 typedef const K& const_reference;
306 constexpr FieldVector ()
312 typename EnableIf =
typename std::enable_if<
313 std::is_convertible<T, K>::value &&
314 ! std::is_base_of<DenseVector<typename FieldTraits<T>::field_type>, K
318 FieldVector (
const T& k) : _data(k) {}
323 std::is_assignable<K&, typename DenseVector<C>::value_type>::value,
int> = 0>
324 FieldVector (
const DenseVector<C> & x)
326 static_assert(((bool)IsFieldVectorSizeCorrect<C,1>::value),
"FieldVectors do not match in dimension!");
327 assert(x.size() == 1);
332 FieldVector(
const FieldVector&) =
default;
335 FieldVector& operator=(
const FieldVector&) =
default;
337 template <
typename T>
338 FieldVector& operator= (
const FieldVector<T, 1>& other)
344 template<
typename T,
int N>
345 FieldVector& operator=(
const FieldVector<T, N>&) =
delete;
348 FieldVector (std::initializer_list<K>
const &l)
350 assert(l.size() == 1);
356 typename EnableIf =
typename std::enable_if<
357 std::is_assignable<K&, T>::value &&
358 ! std::is_base_of<DenseVector<typename FieldTraits<T>::field_type>, K
362 inline FieldVector& operator= (
const T& k)
369 static constexpr size_type size () {
return 1; }
371 K & operator[]([[maybe_unused]] size_type i)
376 const K & operator[]([[maybe_unused]] size_type i)
const
389 const K* data() const noexcept
397 operator K& () {
return _data; }
400 operator const K& ()
const {
return _data; }
408 inline bool operator> (
const FieldVector<K,1>& a,
const FieldVector<K,1>& b)
415 inline bool operator>= (
const FieldVector<K,1>& a,
const FieldVector<K,1>& b)
422 inline bool operator< (
const FieldVector<K,1>& a,
const FieldVector<K,1>& b)
429 inline bool operator<= (
const FieldVector<K,1>& a,
const FieldVector<K,1>& b)
438 inline FieldVector<K,1> operator+ (
const FieldVector<K,1>& a,
const K b)
445 inline FieldVector<K,1> operator- (
const FieldVector<K,1>& a,
const K b)
452 inline FieldVector<K,1> operator* (
const FieldVector<K,1>& a,
const K b)
459 inline FieldVector<K,1> operator/ (
const FieldVector<K,1>& a,
const K b)
466 inline bool operator> (
const FieldVector<K,1>& a,
const K b)
473 inline bool operator>= (
const FieldVector<K,1>& a,
const K b)
480 inline bool operator< (
const FieldVector<K,1>& a,
const K b)
487 inline bool operator<= (
const FieldVector<K,1>& a,
const K b)
494 inline bool operator== (
const FieldVector<K,1>& a,
const K b)
501 inline bool operator!= (
const FieldVector<K,1>& a,
const K b)
510 inline FieldVector<K,1> operator+ (
const K a,
const FieldVector<K,1>& b)
517 inline FieldVector<K,1> operator- (
const K a,
const FieldVector<K,1>& b)
524 inline FieldVector<K,1> operator* (
const K a,
const FieldVector<K,1>& b)
531 inline FieldVector<K,1> operator/ (
const K a,
const FieldVector<K,1>& b)
538 inline bool operator> (
const K a,
const FieldVector<K,1>& b)
545 inline bool operator>= (
const K a,
const FieldVector<K,1>& b)
552 inline bool operator< (
const K a,
const FieldVector<K,1>& b)
559 inline bool operator<= (
const K a,
const FieldVector<K,1>& b)
566 inline bool operator== (
const K a,
const FieldVector<K,1>& b)
573 inline bool operator!= (
const K a,
const FieldVector<K,1>& b)
580 namespace MathOverloads {
583 template<
class K,
int SIZE>
586 for(
int i=0; i<SIZE; i++) {
587 out &= Dune::isFinite(b[i]);
593 template<
class K,
int SIZE>
596 for(
int i=0; i<SIZE; i++) {
597 out |= Dune::isInf(b[i]);
603 template<class K, int SIZE, typename = std::enable_if_t<HasNaN<K>::value>>
606 for(
int i=0; i<SIZE; i++) {
607 out |= Dune::isNaN(b[i]);
613 template<class K, typename = std::enable_if_t<HasNaN<K>::value>>
616 return Dune::isUnordered(b[0],c[0]);
Type traits to determine the type of reals (when working with complex numbers)
Compute type of the result of an arithmetic operation involving two different number types.
Traits for type conversions and type information.
A few common exception classes.
Some useful basic math stuff.
Macro for wrapping boundary checks.
Implements the dense vector interface, with an exchangeable storage class.
#define DUNE_ASSERT_BOUNDS(cond)
If DUNE_CHECK_BOUNDS is defined: check if condition cond holds; otherwise, do nothing.
Definition boundschecking.hh:30
bigunsignedint< k > operator*(const bigunsignedint< k > &x, std::uintmax_t y)
Definition bigunsignedint.hh:549
bigunsignedint< k > operator/(const bigunsignedint< k > &x, std::uintmax_t y)
Definition bigunsignedint.hh:556
Dune namespace.
Definition alignedallocator.hh:13
bool isNaN(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
Definition fvector.hh:604
bool isInf(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
Definition fvector.hh:594
auto isFinite(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
Definition fvector.hh:584
bool isUnordered(const FieldVector< K, 1 > &b, const FieldVector< K, 1 > &c, PriorityTag< 2 >, ADLTag)
Definition fvector.hh:614
vector space out of a tensor product of fields.
Definition fvector.hh:95
K * data() noexcept
return pointer to underlying array
Definition fvector.hh:198
constexpr FieldVector()
Constructor making default-initialized vector.
Definition fvector.hh:112
const value_type & const_reference
The type used for const references to the vector entry.
Definition fvector.hh:109
Base::size_type size_type
Definition fvector.hh:102
FieldVector(const DenseVector< C > &x, typename std::enable_if< IsFieldVectorSizeCorrect< C, SIZE >::value >::type *dummy=0)
Copy constructor from a second vector of possibly different type.
Definition fvector.hh:165
FieldVector(const FieldVector< T, N > &)=delete
FieldVector(const K &t)
Constructor making vector with identical coordinates.
Definition fvector.hh:117
FieldVector(std::initializer_list< K > const &l)
Construct from a std::initializer_list.
Definition fvector.hh:132
const K * data() const noexcept
return pointer to underlying array
Definition fvector.hh:204
static constexpr int dimension
The size of this vector.
Definition fvector.hh:100
FieldVector(const FieldVector< K1, SIZE > &x)
Constructor making vector with identical coordinates.
Definition fvector.hh:175
static constexpr size_type size()
Definition fvector.hh:186
K & operator[](size_type i)
Definition fvector.hh:188
value_type & reference
The type used for references to the vector entry.
Definition fvector.hh:106
Base::value_type value_type
Definition fvector.hh:103
const K & operator[](size_type i) const
Definition fvector.hh:192
FieldVector & operator=(const FieldVector< T, N > &)=delete
FieldVector(const FieldVector &)=default
Copy constructor.
Interface for a class of dense vectors over a given field.
Definition densevector.hh:229
Traits::value_type value_type
export the type representing the field
Definition densevector.hh:250
Iterator begin()
begin iterator
Definition densevector.hh:347
size_type size() const
size method
Definition densevector.hh:336
Traits::size_type size_type
The type used for the index access and size operation.
Definition densevector.hh:259
T field_type
export the type representing the field
Definition ftraits.hh:28
T real_type
export the type representing the real type of the field
Definition ftraits.hh:30
K value_type
Definition fvector.hh:45
std::array< K, SIZE > container_type
Definition fvector.hh:44
container_type::size_type size_type
Definition fvector.hh:46
FieldVector< K, SIZE > derived_type
Definition fvector.hh:43
FieldTraits< K >::real_type real_type
Definition fvector.hh:53
FieldTraits< K >::field_type field_type
Definition fvector.hh:52
TMP to check the size of a DenseVectors statically, if possible.
Definition fvector.hh:66
static constexpr bool value
True if C is not of type FieldVector or its dimension is not equal SIZE.
Definition fvector.hh:71
Tag to make sure the functions in this namespace can be found by ADL.
Definition math.hh:230
Definition matvectraits.hh:31
Helper class for tagging priorities.
Definition typeutilities.hh:73