3 #ifndef DUNE_FVECTOR_HH
4 #define DUNE_FVECTOR_HH
12 #include <initializer_list>
36 template<
class K,
int SIZE >
class FieldVector;
37 template<
class K,
int SIZE >
43 typedef typename container_type::size_type
size_type;
46 template<
class K,
int SIZE >
61 template<
typename C,
int SIZE>
73 template<
typename T,
int SIZE>
79 template<
typename T,
int SIZE,
int SIZE1>
91 template<
class K,
int SIZE >
93 public DenseVector< FieldVector<K,SIZE> >
95 Dune::array<K,SIZE> _data;
96 typedef DenseVector< FieldVector<K,SIZE> > Base;
125 std::copy_n(l.begin(), std::min(static_cast<std::size_t>(
dimension),
146 assert(x.
size() == SIZE);
147 std::copy_n(x.
begin(), std::min(static_cast<std::size_t>(SIZE),x.
size()), _data.begin());
151 template<
class K1,
int SIZE1>
154 static_assert(SIZE1 == SIZE,
"FieldVector in constructor has wrong size");
158 using Base::operator=;
167 void fill(
const K&
t)
169 for (
int i=0; i<SIZE; i++) _data[i]=t;
184 template<
class K,
int SIZE>
201 typedef K container_type;
202 typedef K value_type;
203 typedef size_t size_type;
209 class FieldVector<K, 1> :
210 public DenseVector< FieldVector<K,1> >
213 typedef DenseVector< FieldVector<K,1> > Base;
232 typename EnableIf =
typename std::enable_if<
233 std::is_convertible<T, K>::value &&
234 ! std::is_same<K, DenseVector<typename FieldTraits<T>::field_type>
244 static_assert(((
bool)IsFieldVectorSizeCorrect<C,1>::value),
"FieldVectors do not match in dimension!");
245 assert(x.size() == 1);
251 : Base(), _data( other._data )
256 typename EnableIf =
typename std::enable_if<
257 std::is_convertible<T, K>::value &&
258 ! std::is_same<K, DenseVector<typename FieldTraits<T>::field_type>
288 operator K& () {
return _data; }
291 operator const K& ()
const {
return _data; }
299 inline bool operator> (
const FieldVector<K,1>& a,
const FieldVector<K,1>& b)
306 inline bool operator>= (
const FieldVector<K,1>& a,
const FieldVector<K,1>& b)
313 inline bool operator< (const FieldVector<K,1>& a,
const FieldVector<K,1>& b)
320 inline bool operator<= (const FieldVector<K,1>& a,
const FieldVector<K,1>& b)
329 inline FieldVector<K,1>
operator+ (
const FieldVector<K,1>& a,
const K b)
336 inline FieldVector<K,1>
operator- (
const FieldVector<K,1>& a,
const K b)
343 inline FieldVector<K,1>
operator* (
const FieldVector<K,1>& a,
const K b)
350 inline FieldVector<K,1>
operator/ (
const FieldVector<K,1>& a,
const K b)
357 inline bool operator> (
const FieldVector<K,1>& a,
const K b)
364 inline bool operator>= (
const FieldVector<K,1>& a,
const K b)
371 inline bool operator< (const FieldVector<K,1>& a,
const K b)
378 inline bool operator<= (const FieldVector<K,1>& a,
const K b)
385 inline bool operator== (
const FieldVector<K,1>& a,
const K b)
392 inline bool operator!= (
const FieldVector<K,1>& a,
const K b)
401 inline FieldVector<K,1>
operator+ (
const K a,
const FieldVector<K,1>& b)
408 inline FieldVector<K,1>
operator- (
const K a,
const FieldVector<K,1>& b)
415 inline FieldVector<K,1>
operator* (
const K a,
const FieldVector<K,1>& b)
422 inline FieldVector<K,1>
operator/ (
const K a,
const FieldVector<K,1>& b)
429 inline bool operator> (
const K a,
const FieldVector<K,1>& b)
436 inline bool operator>= (
const K a,
const FieldVector<K,1>& b)
443 inline bool operator< (const K a, const FieldVector<K,1>& b)
450 inline bool operator<= (const K a, const FieldVector<K,1>& b)
457 inline bool operator== (
const K a,
const FieldVector<K,1>& b)
464 inline bool operator!= (
const K a,
const FieldVector<K,1>& b)
FieldVector(const FieldVector &x)
Constructor making vector with identical coordinates.
Definition: fvector.hh:119
The size of this vector.
Definition: fvector.hh:101
size_type size() const
size method
Definition: densevector.hh:296
FieldTraits< K >::field_type field_type
Definition: fvector.hh:49
std::istream & operator>>(std::istream &is, tuple< T1 > &t)
Read a tuple.
Definition: tuples.hh:203
Definition: fvector.hh:69
FieldTraits< K >::real_type real_type
Definition: fvector.hh:50
Definition: ftraits.hh:22
#define DUNE_CONSTEXPR
Set method or expression constexpr if supported by the compiler.
Definition: constexpr.hh:21
bigunsignedint< k > operator/(const bigunsignedint< k > &x, std::uintmax_t y)
Definition: bigunsignedint.hh:534
A few common exception classes.
bigunsignedint< k > operator*(const bigunsignedint< k > &x, std::uintmax_t y)
Definition: bigunsignedint.hh:527
DUNE_CONSTEXPR size_type vec_size() const
Definition: fvector.hh:163
T real_type
export the type representing the real type of the field
Definition: ftraits.hh:27
Definition: matvectraits.hh:29
K & vec_access(size_type i)
Definition: fvector.hh:164
bigunsignedint< k > operator-(const bigunsignedint< k > &x, std::uintmax_t y)
Definition: bigunsignedint.hh:520
Fallback implementation of the std::array class (a static array)
FieldVector(const K &t)
Constructor making vector with identical coordinates.
Definition: fvector.hh:113
Base::value_type value_type
Definition: fvector.hh:105
K value_type
Definition: fvector.hh:42
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:672
DUNE_CONSTEXPR size_type size() const
Definition: fvector.hh:160
FieldVector()
Constructor making default-initialized vector.
Definition: fvector.hh:108
T t
Definition: alignment.hh:34
FieldVector< K, SIZE > derived_type
Definition: fvector.hh:40
Implements the dense vector interface, with an exchangeable storage class.
Definition of the DUNE_UNUSED macro for the case that config.h is not available.
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:230
Type traits to determine the type of reals (when working with complex numbers)
FieldVector(const FieldVector< K1, SIZE1 > &x)
Constructor making vector with identical coordinates.
Definition: fvector.hh:152
bigunsignedint< k > operator+(const bigunsignedint< k > &x, std::uintmax_t y)
Definition: bigunsignedint.hh:513
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:252
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:694
vector space out of a tensor product of fields.
Definition: densematrix.hh:36
#define DUNE_UNUSED_PARAMETER(parm)
A macro to mark intentional unused function parameters with.
Definition: unused.hh:18
derived_type & operator=(const value_type &k)
Assignment operator for scalar.
Definition: densevector.hh:275
T field_type
export the type representing the field
Definition: ftraits.hh:25
TMP to check the size of a DenseVectors statically, if possible.
Definition: fvector.hh:62
const K & vec_access(size_type i) const
Definition: fvector.hh:165
Definition of the DUNE_CONSTEXPR macro.
Iterator begin()
begin iterator
Definition: densevector.hh:307
container_type::size_type size_type
Definition: fvector.hh:43
Base::size_type size_type
Definition: fvector.hh:104
FieldVector(std::initializer_list< K > const &l)
Definition: fvector.hh:122
Traits for type conversions and type information.
Dune::array< K, SIZE > container_type
Definition: fvector.hh:41
Traits::size_type size_type
The type used for the index access and size operation.
Definition: densevector.hh:265
Traits::value_type value_type
export the type representing the field
Definition: densevector.hh:256
FieldVector(const DenseVector< C > &x, typename Dune::enable_if< IsFieldVectorSizeCorrect< C, SIZE >::value >::type *dummy=0)
Copy constructor from a second vector of possibly different type.
Definition: fvector.hh:142