13#include <initializer_list>
17#include "exceptions.hh"
38 template<
class K,
int SIZE >
class FieldVector;
39 template<
class K,
int SIZE >
40 struct DenseMatVecTraits< FieldVector<K,SIZE> >
42 typedef FieldVector<K,SIZE> derived_type;
43 typedef std::array<K,SIZE> container_type;
45 typedef typename container_type::size_type size_type;
48 template<
class K,
int SIZE >
49 struct FieldTraits< FieldVector<K,SIZE> >
51 typedef typename FieldTraits<K>::field_type field_type;
52 typedef typename FieldTraits<K>::real_type real_type;
63 template<
typename C,
int SIZE>
75 template<
typename T,
int SIZE>
76 struct IsFieldVectorSizeCorrect<FieldVector<T,SIZE>,SIZE>
81 template<
typename T,
int SIZE,
int SIZE1>
82 struct IsFieldVectorSizeCorrect<FieldVector<T,SIZE1>,SIZE>
93 template<
class K,
int SIZE >
97 std::array<K,SIZE> _data;
123 std::fill(_data.begin(),_data.end(),t);
126#if __GNUC__ == 5 && !defined(__clang__)
138 assert(l.size() == dimension);
139 std::copy_n(l.begin(),
std::min(
static_cast<std::size_t
>(dimension),
147 template <
typename T>
150 std::copy_n(x.
begin(), SIZE, _data.begin());
154 template<
typename T,
int N>
173 assert(x.
size() == SIZE);
174 std::copy_n(x.
begin(),
std::min(
static_cast<std::size_t
>(SIZE),x.
size()), _data.begin());
181 std::copy_n(x.
begin(), SIZE, _data.begin());
184 template<
typename T,
int N>
187 using Base::operator=;
190 static constexpr size_type size () {
return SIZE; }
192 K & operator[](size_type i) {
196 const K & operator[](size_type i)
const {
215 std::enable_if_t<IsNumber<Scalar>::value,
int> = 0>
220 for (size_type i = 0; i < vector.size(); ++i)
221 result[i] = vector[i] * scalar;
228 std::enable_if_t<IsNumber<Scalar>::value,
int> = 0>
233 for (size_type i = 0; i < vector.size(); ++i)
234 result[i] = scalar * vector[i];
241 std::enable_if_t<IsNumber<Scalar>::value,
int> = 0>
246 for (size_type i = 0; i < vector.size(); ++i)
247 result[i] = vector[i] / scalar;
265 template<
class K,
int SIZE>
270 for(
typename FieldVector<K, SIZE>::size_type i = 0; i < SIZE; ++i )
282 typedef K container_type;
283 typedef K value_type;
284 typedef size_t size_type;
290 class FieldVector<K, 1> :
291 public DenseVector< FieldVector<K,1> >
294 typedef DenseVector< FieldVector<K,1> > Base;
302 typedef typename Base::size_type size_type;
305 typedef K& reference;
308 typedef const K& const_reference;
313 constexpr FieldVector ()
319 typename EnableIf =
typename std::enable_if<
320 std::is_convertible<T, K>::value &&
321 ! std::is_base_of<DenseVector<typename FieldTraits<T>::field_type>, K
325 FieldVector (
const T& k) : _data(k) {}
330 std::is_assignable<K&, typename DenseVector<C>::value_type>::value,
int> = 0>
331 FieldVector (
const DenseVector<C> & x)
333 static_assert(((bool)IsFieldVectorSizeCorrect<C,1>::value),
"FieldVectors do not match in dimension!");
334 assert(x.size() == 1);
339 FieldVector(
const FieldVector&) =
default;
342 FieldVector& operator=(
const FieldVector&) =
default;
344 template <
typename T>
345 FieldVector& operator= (
const FieldVector<T, 1>& other)
351 template<
typename T,
int N>
352 FieldVector& operator=(
const FieldVector<T, N>&) =
delete;
355 FieldVector (std::initializer_list<K>
const &l)
357 assert(l.size() == 1);
363 typename EnableIf =
typename std::enable_if<
364 std::is_assignable<K&, T>::value &&
365 ! std::is_base_of<DenseVector<typename FieldTraits<T>::field_type>, K
369 inline FieldVector& operator= (
const T& k)
376 static constexpr size_type size () {
return 1; }
378 K & operator[](size_type i)
384 const K & operator[](size_type i)
const
398 const K* data() const noexcept
406 operator K& () {
return _data; }
409 operator const K& ()
const {
return _data; }
417 inline bool operator> (
const FieldVector<K,1>& a,
const FieldVector<K,1>& b)
424 inline bool operator>= (
const FieldVector<K,1>& a,
const FieldVector<K,1>& b)
431 inline bool operator< (
const FieldVector<K,1>& a,
const FieldVector<K,1>& b)
438 inline bool operator<= (
const FieldVector<K,1>& a,
const FieldVector<K,1>& b)
447 inline FieldVector<K,1> operator+ (
const FieldVector<K,1>& a,
const K b)
454 inline FieldVector<K,1> operator- (
const FieldVector<K,1>& a,
const K b)
461 inline FieldVector<K,1> operator* (
const FieldVector<K,1>& a,
const K b)
468 inline FieldVector<K,1> operator/ (
const FieldVector<K,1>& a,
const K b)
475 inline bool operator> (
const FieldVector<K,1>& a,
const K b)
482 inline bool operator>= (
const FieldVector<K,1>& a,
const K b)
489 inline bool operator< (
const FieldVector<K,1>& a,
const K b)
496 inline bool operator<= (
const FieldVector<K,1>& a,
const K b)
503 inline bool operator== (
const FieldVector<K,1>& a,
const K b)
510 inline bool operator!= (
const FieldVector<K,1>& a,
const K b)
519 inline FieldVector<K,1> operator+ (
const K a,
const FieldVector<K,1>& b)
526 inline FieldVector<K,1> operator- (
const K a,
const FieldVector<K,1>& b)
533 inline FieldVector<K,1> operator* (
const K a,
const FieldVector<K,1>& b)
540 inline FieldVector<K,1> operator/ (
const K a,
const FieldVector<K,1>& b)
547 inline bool operator> (
const K a,
const FieldVector<K,1>& b)
554 inline bool operator>= (
const K a,
const FieldVector<K,1>& b)
561 inline bool operator< (
const K a,
const FieldVector<K,1>& b)
568 inline bool operator<= (
const K a,
const FieldVector<K,1>& b)
575 inline bool operator== (
const K a,
const FieldVector<K,1>& b)
582 inline bool operator!= (
const K a,
const FieldVector<K,1>& b)
589 namespace MathOverloads {
592 template<
class K,
int SIZE>
595 for(
int i=0; i<SIZE; i++) {
596 out &= Dune::isFinite(b[i]);
602 template<
class K,
int SIZE>
605 for(
int i=0; i<SIZE; i++) {
606 out |= Dune::isInf(b[i]);
612 template<class K, int SIZE, typename = std::enable_if_t<HasNaN<K>::value>>
615 for(
int i=0; i<SIZE; i++) {
616 out |= Dune::isNaN(b[i]);
622 template<class K, typename = std::enable_if_t<HasNaN<K>::value>>
625 return Dune::isUnordered(b[0],c[0]);
Macro for wrapping boundary checks.
Interface for a class of dense vectors over a given field.
Definition: densevector.hh:227
Traits::value_type value_type
export the type representing the field
Definition: densevector.hh:248
Iterator begin()
begin iterator
Definition: densevector.hh:348
size_type size() const
size method
Definition: densevector.hh:337
Traits::size_type size_type
The type used for the index access and size operation.
Definition: densevector.hh:257
vector space out of a tensor product of fields.
Definition: fvector.hh:96
K * data() noexcept
return pointer to underlying array
Definition: fvector.hh:202
constexpr FieldVector()
Constructor making default-initialized vector.
Definition: fvector.hh:116
const value_type & const_reference
The type used for const references to the vector entry.
Definition: fvector.hh:113
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:169
FieldVector(const K &t)
Constructor making vector with identical coordinates.
Definition: fvector.hh:121
FieldVector(std::initializer_list< K > const &l)
Construct from a std::initializer_list.
Definition: fvector.hh:136
const K * data() const noexcept
return pointer to underlying array
Definition: fvector.hh:208
@ dimension
The size of this vector.
Definition: fvector.hh:103
FieldVector(const FieldVector< K1, SIZE > &x)
Constructor making vector with identical coordinates.
Definition: fvector.hh:179
value_type & reference
The type used for references to the vector entry.
Definition: fvector.hh:110
FieldVector(const FieldVector &)=default
Copy constructor.
Implements the dense vector interface, with an exchangeable storage class.
Type traits to determine the type of reals (when working with complex numbers)
#define DUNE_ASSERT_BOUNDS(cond)
If DUNE_CHECK_BOUNDS is defined: check if condition cond holds; otherwise, do nothing.
Definition: boundschecking.hh:28
#define DUNE_UNUSED_PARAMETER(parm)
A macro to mark intentionally unused function parameters with.
Definition: unused.hh:25
std::istream & operator>>(std::istream &in, DynamicVector< K, Allocator > &v)
Read a DynamicVector from an input stream.
Definition: dynvector.hh:187
EnableIfInterOperable< T1, T2, bool >::type operator<(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition: iteratorfacades.hh:635
EnableIfInterOperable< T1, T2, bool >::type operator>(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition: iteratorfacades.hh:681
EnableIfInterOperable< T1, T2, bool >::type operator<=(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition: iteratorfacades.hh:658
EnableIfInterOperable< T1, T2, bool >::type operator==(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for equality.
Definition: iteratorfacades.hh:235
EnableIfInterOperable< T1, T2, bool >::type operator>=(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition: iteratorfacades.hh:703
EnableIfInterOperable< T1, T2, bool >::type operator!=(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for inequality.
Definition: iteratorfacades.hh:257
auto min(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::min()
Definition: defaults.hh:87
typename Overloads::ScalarType< std::decay_t< V > >::type Scalar
Element type of some SIMD type.
Definition: interface.hh:233
Some useful basic math stuff.
Dune namespace.
Definition: alignedallocator.hh:14
TMP to check the size of a DenseVectors statically, if possible.
Definition: fvector.hh:65
@ value
Definition: fvector.hh:71
Tag to make sure the functions in this namespace can be found by ADL.
Definition: math.hh:227
Helper class for tagging priorities.
Definition: typeutilities.hh:71
Traits for type conversions and type information.
Definition of the DUNE_UNUSED macro for the case that config.h is not available.