Go to the documentation of this file.
3 #ifndef DUNE_FVECTOR_HH
4 #define DUNE_FVECTOR_HH
13 #include <initializer_list>
38 template<
class K,
int SIZE >
class FieldVector;
39 template<
class K,
int SIZE >
45 typedef typename container_type::size_type
size_type;
48 template<
class K,
int SIZE >
63 template<
typename C,
int SIZE>
75 template<
typename T,
int SIZE>
81 template<
typename T,
int SIZE,
int SIZE1>
93 template<
class K,
int SIZE >
95 public DenseVector< FieldVector<K,SIZE> >
97 std::array<K,SIZE> _data;
98 typedef DenseVector< FieldVector<K,SIZE> > Base;
123 std::fill(_data.begin(),_data.end(),t);
126 #if __GNUC__ == 5 && !defined(__clang__)
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=;
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>
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;
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
330 std::is_assignable<K&, typename DenseVector<C>::value_type>::value,
int> = 0>
334 assert(x.size() == 1);
344 template <
typename T>
351 template<
typename T,
int N>
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
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++) {
602 template<
class K,
int SIZE>
605 for(
int i=0; i<SIZE; i++) {
612 template<class K, int SIZE, typename = std::enable_if_t<HasNaN<K>::value>>
615 for(
int i=0; i<SIZE; i++) {
622 template<class K, typename = std::enable_if_t<HasNaN<K>::value>>
K * data() noexcept
return pointer to underlying array
Definition: fvector.hh:202
K & operator[](size_type i)
Definition: fvector.hh:192
A few common exception classes.
FieldTraits< K >::real_type real_type
Definition: fvector.hh:52
FieldVector(const K &t)
Constructor making vector with identical coordinates.
Definition: fvector.hh:121
T real_type
export the type representing the real type of the field
Definition: ftraits.hh:28
TMP to check the size of a DenseVectors statically, if possible.
Definition: fvector.hh:64
Helper class for tagging priorities.
Definition: typeutilities.hh:70
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
auto isFinite(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
Definition: fvector.hh:593
Compute type of the result of an arithmetic operation involving two different number types.
auto min(const AlignedNumber< T, align > &a, const AlignedNumber< T, align > &b)
Definition: debugalign.hh:434
bigunsignedint< k > operator*(const bigunsignedint< k > &x, std::uintmax_t y)
Definition: bigunsignedint.hh:544
static constexpr size_type size()
Definition: fvector.hh:190
size_type size() const
size method
Definition: densevector.hh:337
Macro for wrapping boundary checks.
#define DUNE_UNUSED_PARAMETER(parm)
A macro to mark intentionally unused function parameters with.
Definition: unused.hh:25
Traits::size_type size_type
The type used for the index access and size operation.
Definition: densevector.hh:257
T field_type
export the type representing the field
Definition: ftraits.hh:26
constexpr FieldVector()
Constructor making default-initialized vector.
Definition: fvector.hh:116
Traits for type conversions and type information.
K value_type
Definition: fvector.hh:44
bigunsignedint< k > operator-(const bigunsignedint< k > &x, std::uintmax_t y)
Definition: bigunsignedint.hh:537
Base::size_type size_type
Definition: fvector.hh:106
FieldTraits< K >::field_type field_type
Definition: fvector.hh:51
friend auto operator*(const FieldVector &vector, Scalar scalar)
vector space multiplication with scalar
Definition: fvector.hh:216
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
constexpr bool operator!=(const DebugAllocator< T > &, const DebugAllocator< T > &)
check whether allocators are not equivalent
Definition: debugallocator.hh:318
FieldVector(const FieldVector< K1, SIZE > &x)
Constructor making vector with identical coordinates.
Definition: fvector.hh:179
FieldVector & operator=(const FieldVector &)=default
copy assignment operator
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< K, SIZE > derived_type
Definition: fvector.hh:42
Iterator begin()
begin iterator
Definition: densevector.hh:348
bool isNaN(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
Definition: fvector.hh:613
FieldVector(std::initializer_list< K > const &l)
Construct from a std::initializer_list.
Definition: fvector.hh:136
Implements the dense vector interface, with an exchangeable storage class.
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
Definition: ftraits.hh:23
Stream & operator>>(Stream &stream, std::tuple< Ts... > &t)
Read a std::tuple.
Definition: streamoperators.hh:41
@ dimension
The size of this vector.
Definition: fvector.hh:103
friend auto operator/(const FieldVector &vector, Scalar scalar)
vector space division by scalar
Definition: fvector.hh:242
const typedef value_type & const_reference
The type used for const references to the vector entry.
Definition: fvector.hh:113
Interface for a class of dense vectors over a given field.
Definition: densevector.hh:20
Definition of the DUNE_UNUSED macro for the case that config.h is not available.
Definition: matvectraits.hh:29
vector space out of a tensor product of fields.
Definition: densematrix.hh:42
Some useful basic math stuff.
const K & operator[](size_type i) const
Definition: fvector.hh:196
@ value
Definition: fvector.hh:71
Tag to make sure the functions in this namespace can be found by ADL.
Definition: math.hh:227
bigunsignedint< k > operator+(const bigunsignedint< k > &x, std::uintmax_t y)
Definition: bigunsignedint.hh:530
bigunsignedint< k > operator/(const bigunsignedint< k > &x, std::uintmax_t y)
Definition: bigunsignedint.hh:551
Traits::value_type value_type
export the type representing the field
Definition: densevector.hh:248
#define DUNE_ASSERT_BOUNDS(cond)
If DUNE_CHECK_BOUNDS is defined: check if condition cond holds; otherwise, do nothing.
Definition: boundschecking.hh:28
const K * data() const noexcept
return pointer to underlying array
Definition: fvector.hh:208
bool isUnordered(const FieldVector< K, 1 > &b, const FieldVector< K, 1 > &c, PriorityTag< 2 >, ADLTag)
Definition: fvector.hh:623
Base::value_type value_type
Definition: fvector.hh:107
bool isInf(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
Definition: fvector.hh:603
Type traits to determine the type of reals (when working with complex numbers)
constexpr bool operator==(const DebugAllocator< T > &, const DebugAllocator< T > &)
check whether allocators are equivalent
Definition: debugallocator.hh:310
typename Overloads::ScalarType< std::decay_t< V > >::type Scalar
Element type of some SIMD type.
Definition: simd/interface.hh:233
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
std::array< K, SIZE > container_type
Definition: fvector.hh:43
value_type & reference
The type used for references to the vector entry.
Definition: fvector.hh:110
Dune namespace.
Definition: alignedallocator.hh:13
container_type::size_type size_type
Definition: fvector.hh:45