27 #ifndef CDPL_MATH_VECTORADAPTER_HPP
28 #define CDPL_MATH_VECTORADAPTER_HPP
30 #include <type_traits>
84 typedef typename std::conditional<std::is_const<V>::value,
85 typename V::ConstReference,
91 typedef typename std::conditional<std::is_const<V>::value,
92 typename V::ConstClosureType,
110 data(v), extElem(1) {}
123 if (i == data.getSize())
140 if (i == data.getSize())
153 if (i == data.getSize())
166 if (i == data.getSize())
178 return (data.getSize() +
SizeType(1));
225 template <
typename E>
238 template <
typename E>
251 template <
typename E>
264 template <
typename T>
267 vectorAssignScalar<ScalarMultiplicationAssignment>(*
this, t);
277 template <
typename T>
280 vectorAssignScalar<ScalarDivisionAssignment>(*
this, t);
290 template <
typename E>
293 vectorAssignVector<ScalarAssignment>(*
this, e);
303 template <
typename E>
306 vectorAssignVector<ScalarAdditionAssignment>(*
this, e);
316 template <
typename E>
319 vectorAssignVector<ScalarSubtractionAssignment>(*
this, e);
352 template <
typename V>
377 typedef typename std::conditional<std::is_const<V>::value,
378 typename V::ConstReference,
384 typedef typename std::conditional<std::is_const<V>::value,
385 typename V::ConstClosureType,
512 template <
typename E>
525 template <
typename T>
542 template <
typename E>
555 template <
typename T>
569 template <
typename E>
582 template <
typename T>
596 template <
typename E>
609 template <
typename T>
613 quaternionAssignScalar<ScalarMultiplicationAssignment>(*
this, t);
623 template <
typename E>
636 template <
typename T>
640 quaternionAssignScalar<ScalarDivisionAssignment>(*
this, t);
651 template <
typename E>
654 quaternionAssignQuaternion<ScalarAssignment>(*
this, e);
664 template <
typename E>
667 quaternionAssignQuaternion<ScalarAdditionAssignment>(*
this, e);
677 template <
typename E>
680 quaternionAssignQuaternion<ScalarSubtractionAssignment>(*
this, e);
724 template <
typename T>
731 template <
typename V>
745 template <
typename V>
759 template <
typename V>
767 template <
typename V>
777 template <
typename E>
790 template <
typename E>
791 VectorQuaternionAdapter<const E>
803 template <
typename E>
804 HomogenousCoordsAdapter<E>
816 template <
typename E>
817 HomogenousCoordsAdapter<const E>
Definition of basic expression types.
Definition of various functors.
Implementation of quaternion assignment routines.
Definition of type traits.
Implementation of vector assignment routines.
Vector expression that exposes a vector V as its homogeneous-coordinate extension by appending an imp...
Definition: VectorAdapter.hpp:51
const SelfType ConstClosureType
Constant closure type used when this adapter appears inside another expression.
Definition: VectorAdapter.hpp:98
std::enable_if< IsScalar< T >::value, HomogenousCoordsAdapter >::type & operator*=(const T &t)
Multiplies every element of this view by the scalar t.
Definition: VectorAdapter.hpp:265
ConstReference operator[](SizeType i) const
Returns a const reference to the element at index i of the view.
Definition: VectorAdapter.hpp:164
HomogenousCoordsAdapter & minusAssign(const VectorExpression< E > &e)
Subtracts the vector expression e from this view without intermediate temporary.
Definition: VectorAdapter.hpp:317
V VectorType
The wrapped vector type.
Definition: VectorAdapter.hpp:59
SelfType ClosureType
Closure type used when this adapter appears inside another expression.
Definition: VectorAdapter.hpp:103
std::conditional< std::is_const< V >::value, typename V::ConstReference, typename V::Reference >::type Reference
Mutable element reference type (degrades to ConstReference when the wrapped vector is const).
Definition: VectorAdapter.hpp:86
Reference operator()(SizeType i)
Returns a mutable reference to the element at index i of the view.
Definition: VectorAdapter.hpp:121
Reference operator[](SizeType i)
Returns a mutable reference to the element at index i of the view.
Definition: VectorAdapter.hpp:151
const VectorClosureType & getData() const
Returns a const reference to the wrapped vector (via its stored closure).
Definition: VectorAdapter.hpp:203
HomogenousCoordsAdapter & operator=(const HomogenousCoordsAdapter &va)
Copies the elements of va into this view (writing through to the wrapped vector and to the extension ...
Definition: VectorAdapter.hpp:213
bool isEmpty() const
Tells whether the view is empty (always false).
Definition: VectorAdapter.hpp:185
std::conditional< std::is_const< V >::value, typename V::ConstClosureType, typename V::ClosureType >::type VectorClosureType
Closure type used to store the wrapped vector internally (mutable or const flavor).
Definition: VectorAdapter.hpp:93
HomogenousCoordsAdapter & operator+=(const VectorExpression< E > &e)
Adds the vector expression e componentwise to this view.
Definition: VectorAdapter.hpp:239
HomogenousCoordsAdapter & operator-=(const VectorExpression< E > &e)
Subtracts the vector expression e componentwise from this view.
Definition: VectorAdapter.hpp:252
SizeType getSize() const
Returns the dimensionality of the view (wrapped vector size + 1).
Definition: VectorAdapter.hpp:176
HomogenousCoordsAdapter(VectorType &v)
Constructs the adapter wrapping v.
Definition: VectorAdapter.hpp:109
HomogenousCoordsAdapter & operator=(const VectorExpression< E > &e)
Assigns the vector expression e to this view (writing through to the wrapped vector).
Definition: VectorAdapter.hpp:226
void swap(HomogenousCoordsAdapter &va)
Swaps the contents of this view with those of va.
Definition: VectorAdapter.hpp:327
V::ValueType ValueType
The element value type of the wrapped vector.
Definition: VectorAdapter.hpp:74
std::enable_if< IsScalar< T >::value, HomogenousCoordsAdapter >::type & operator/=(const T &t)
Divides every element of this view by the scalar t.
Definition: VectorAdapter.hpp:278
V::ConstReference ConstReference
Constant element reference type.
Definition: VectorAdapter.hpp:79
ConstReference operator()(SizeType i) const
Returns a const reference to the element at index i of the view.
Definition: VectorAdapter.hpp:138
V::DifferenceType DifferenceType
The signed difference type used by the wrapped vector.
Definition: VectorAdapter.hpp:69
HomogenousCoordsAdapter & plusAssign(const VectorExpression< E > &e)
Adds the vector expression e to this view without intermediate temporary.
Definition: VectorAdapter.hpp:304
VectorClosureType & getData()
Returns a reference to the wrapped vector (via its stored closure).
Definition: VectorAdapter.hpp:194
friend void swap(HomogenousCoordsAdapter &va1, HomogenousCoordsAdapter &va2)
ADL-enabled free-function form of swap().
Definition: VectorAdapter.hpp:338
V::SizeType SizeType
The size type used by the wrapped vector.
Definition: VectorAdapter.hpp:64
HomogenousCoordsAdapter & assign(const VectorExpression< E > &e)
Assigns the vector expression e to this view without intermediate temporary.
Definition: VectorAdapter.hpp:291
CRTP base class of all quaternion expression types.
Definition: Expression.hpp:148
General 4-component quaternion .
Definition: Quaternion.hpp:413
CRTP base class of all vector expression types.
Definition: Expression.hpp:68
Quaternion expression that exposes a 4-element vector as a quaternion (component indices 0-3 map to C...
Definition: VectorAdapter.hpp:354
VectorQuaternionAdapter & assign(const QuaternionExpression< E > &e)
Assigns the quaternion expression e to this view without intermediate temporary (use only when e does...
Definition: VectorAdapter.hpp:652
Reference getC4()
Returns a mutable reference to the imaginary component C4.
Definition: VectorAdapter.hpp:436
Reference getC3()
Returns a mutable reference to the imaginary component C3.
Definition: VectorAdapter.hpp:427
VectorClosureType & getData()
Returns a reference to the wrapped vector (via its stored closure).
Definition: VectorAdapter.hpp:481
V VectorType
The wrapped 4-element vector type.
Definition: VectorAdapter.hpp:362
ConstReference getC4() const
Returns a const reference to the imaginary component C4.
Definition: VectorAdapter.hpp:472
ConstReference getC1() const
Returns a const reference to the real component C1.
Definition: VectorAdapter.hpp:445
std::enable_if< IsScalar< T >::value, VectorQuaternionAdapter >::type & operator-=(const T &t)
Subtracts the scalar t from component C1 of this view.
Definition: VectorAdapter.hpp:584
std::conditional< std::is_const< V >::value, typename V::ConstClosureType, typename V::ClosureType >::type VectorClosureType
Closure type used to store the wrapped vector internally.
Definition: VectorAdapter.hpp:386
V::ValueType ValueType
The element value type.
Definition: VectorAdapter.hpp:367
ConstReference getC2() const
Returns a const reference to the imaginary component C2.
Definition: VectorAdapter.hpp:454
VectorQuaternionAdapter & plusAssign(const QuaternionExpression< E > &e)
Adds the quaternion expression e to this view without intermediate temporary.
Definition: VectorAdapter.hpp:665
std::enable_if< IsScalar< T >::value, VectorQuaternionAdapter >::type & operator+=(const T &t)
Adds the scalar t to component C1 of this view.
Definition: VectorAdapter.hpp:557
void set(const ValueType &c1=ValueType(), const ValueType &c2=ValueType(), const ValueType &c3=ValueType(), const ValueType &c4=ValueType())
Assigns the four supplied component values to this view (writing through to the wrapped vector).
Definition: VectorAdapter.hpp:711
ConstReference getC3() const
Returns a const reference to the imaginary component C3.
Definition: VectorAdapter.hpp:463
VectorQuaternionAdapter & operator+=(const QuaternionExpression< E > &e)
Adds the quaternion expression e componentwise to this view.
Definition: VectorAdapter.hpp:543
const VectorClosureType & getData() const
Returns a const reference to the wrapped vector (via its stored closure).
Definition: VectorAdapter.hpp:490
Reference getC1()
Returns a mutable reference to the real component C1.
Definition: VectorAdapter.hpp:409
SelfType ClosureType
Closure type used when this adapter appears inside another expression.
Definition: VectorAdapter.hpp:396
VectorQuaternionAdapter & operator*=(const QuaternionExpression< E > &e)
Multiplies this view by the quaternion expression e (Hamilton-product semantics).
Definition: VectorAdapter.hpp:597
std::conditional< std::is_const< V >::value, typename V::ConstReference, typename V::Reference >::type Reference
Mutable component reference type (degrades to ConstReference when the wrapped vector is const).
Definition: VectorAdapter.hpp:379
friend void swap(VectorQuaternionAdapter &va1, VectorQuaternionAdapter &va2)
ADL-enabled free-function form of swap().
Definition: VectorAdapter.hpp:699
std::enable_if< IsScalar< T >::value, VectorQuaternionAdapter >::type & operator=(const T &t)
Assigns the scalar t to this view (sets C1 to t and the remaining components to the default value).
Definition: VectorAdapter.hpp:527
void swap(VectorQuaternionAdapter &va)
Swaps the components of this view with those of va.
Definition: VectorAdapter.hpp:688
std::enable_if< IsScalar< T >::value, VectorQuaternionAdapter >::type & operator/=(const T &t)
Divides every component of this view by the scalar t.
Definition: VectorAdapter.hpp:638
VectorQuaternionAdapter(VectorType &v)
Constructs the adapter wrapping the 4-element vector v.
Definition: VectorAdapter.hpp:402
V::ConstReference ConstReference
Constant component reference type.
Definition: VectorAdapter.hpp:372
Reference getC2()
Returns a mutable reference to the imaginary component C2.
Definition: VectorAdapter.hpp:418
std::enable_if< IsScalar< T >::value, VectorQuaternionAdapter >::type & operator*=(const T &t)
Multiplies every component of this view by the scalar t.
Definition: VectorAdapter.hpp:611
VectorQuaternionAdapter & operator=(const VectorQuaternionAdapter &va)
Copies the components of va into this view (writing through to the wrapped vector).
Definition: VectorAdapter.hpp:500
const SelfType ConstClosureType
Constant closure type used when this adapter appears inside another expression.
Definition: VectorAdapter.hpp:391
VectorQuaternionAdapter & minusAssign(const QuaternionExpression< E > &e)
Subtracts the quaternion expression e from this view without intermediate temporary.
Definition: VectorAdapter.hpp:678
VectorQuaternionAdapter & operator=(const QuaternionExpression< E > &e)
Assigns the quaternion expression e to this view (writing through to the wrapped vector).
Definition: VectorAdapter.hpp:513
VectorQuaternionAdapter & operator-=(const QuaternionExpression< E > &e)
Subtracts the quaternion expression e componentwise from this view.
Definition: VectorAdapter.hpp:570
VectorQuaternionAdapter & operator/=(const QuaternionExpression< E > &e)
Divides this view by the quaternion expression e (Hamilton-quotient semantics).
Definition: VectorAdapter.hpp:624
constexpr unsigned int V
Specifies Vanadium.
Definition: AtomType.hpp:177
constexpr unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
HomogenousCoordsAdapter< E > homog(VectorExpression< E > &me)
Returns a mutable vector adapter that exposes me as its homogeneous-coordinate extension.
Definition: VectorAdapter.hpp:805
void quaternionSwap(Q &q, QuaternionExpression< E > &e)
Swaps the components of two quaternion expressions component by component.
Definition: QuaternionAssignment.hpp:93
void vectorSwap(V &v, VectorExpression< E > &e)
Swaps the elements of two equally sized vector expressions element by element.
Definition: VectorAssignment.hpp:97
std::enable_if< IsScalar< T >::value, RealQuaternion< T > >::type quat(const T &t)
Constructs a Math::RealQuaternion from the scalar t (its real component).
Definition: Quaternion.hpp:1212
The namespace of the Chemical Data Processing Library.
Quaternion< typename V::ValueType > Type
The Math::Quaternion specialization used as the temporary quaternion type.
Definition: VectorAdapter.hpp:738
Quaternion< typename V::ValueType > Type
The Math::Quaternion specialization used as the temporary quaternion type.
Definition: VectorAdapter.hpp:752
Selects a concrete temporary quaternion type compatible with the quaternion expression Q.
Definition: TypeTraits.hpp:351
Q::QuaternionTemporaryType Type
The concrete temporary quaternion type compatible with the quaternion expression Q.
Definition: TypeTraits.hpp:356
Selects a concrete temporary vector type compatible with the vector expression V.
Definition: TypeTraits.hpp:323
V::VectorTemporaryType Type
The concrete temporary vector type compatible with the vector expression V.
Definition: TypeTraits.hpp:328