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())
136 if (i == data.getSize())
149 if (i == data.getSize())
162 if (i == data.getSize())
174 return (data.getSize() +
SizeType(1));
221 template <
typename E>
234 template <
typename E>
247 template <
typename E>
260 template <
typename T>
263 vectorAssignScalar<ScalarMultiplicationAssignment>(*
this, t);
273 template <
typename T>
276 vectorAssignScalar<ScalarDivisionAssignment>(*
this, t);
286 template <
typename E>
289 vectorAssignVector<ScalarAssignment>(*
this, e);
299 template <
typename E>
302 vectorAssignVector<ScalarAdditionAssignment>(*
this, e);
312 template <
typename E>
315 vectorAssignVector<ScalarSubtractionAssignment>(*
this, e);
348 template <
typename V>
373 typedef typename std::conditional<std::is_const<V>::value,
374 typename V::ConstReference,
380 typedef typename std::conditional<std::is_const<V>::value,
381 typename V::ConstClosureType,
508 template <
typename E>
521 template <
typename T>
538 template <
typename E>
551 template <
typename T>
565 template <
typename E>
578 template <
typename T>
592 template <
typename E>
605 template <
typename T>
609 quaternionAssignScalar<ScalarMultiplicationAssignment>(*
this, t);
619 template <
typename E>
632 template <
typename T>
636 quaternionAssignScalar<ScalarDivisionAssignment>(*
this, t);
647 template <
typename E>
650 quaternionAssignQuaternion<ScalarAssignment>(*
this, e);
660 template <
typename E>
663 quaternionAssignQuaternion<ScalarAdditionAssignment>(*
this, e);
673 template <
typename E>
676 quaternionAssignQuaternion<ScalarSubtractionAssignment>(*
this, e);
720 template <
typename T>
727 template <
typename V>
741 template <
typename V>
755 template <
typename V>
763 template <
typename V>
773 template <
typename E>
786 template <
typename E>
787 VectorQuaternionAdapter<const E>
799 template <
typename E>
800 HomogenousCoordsAdapter<E>
812 template <
typename E>
813 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:261
ConstReference operator[](SizeType i) const
Returns a const reference to the element at index i of the view.
Definition: VectorAdapter.hpp:160
HomogenousCoordsAdapter & minusAssign(const VectorExpression< E > &e)
Subtracts the vector expression e from this view without intermediate temporary.
Definition: VectorAdapter.hpp:313
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:147
const VectorClosureType & getData() const
Returns a const reference to the wrapped vector (via its stored closure).
Definition: VectorAdapter.hpp:199
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:209
bool isEmpty() const
Tells whether the view is empty (always false; the view always has at least the extension element).
Definition: VectorAdapter.hpp:181
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:235
HomogenousCoordsAdapter & operator-=(const VectorExpression< E > &e)
Subtracts the vector expression e componentwise from this view.
Definition: VectorAdapter.hpp:248
SizeType getSize() const
Returns the dimensionality of the view (wrapped vector size + 1).
Definition: VectorAdapter.hpp:172
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:222
void swap(HomogenousCoordsAdapter &va)
Swaps the contents of this view with those of va.
Definition: VectorAdapter.hpp:323
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:274
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:134
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:300
VectorClosureType & getData()
Returns a reference to the wrapped vector (via its stored closure).
Definition: VectorAdapter.hpp:190
friend void swap(HomogenousCoordsAdapter &va1, HomogenousCoordsAdapter &va2)
ADL-enabled free-function form of swap().
Definition: VectorAdapter.hpp:334
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:287
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:350
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:648
Reference getC4()
Returns a mutable reference to component C4 (mapped to element 3 of the wrapped vector).
Definition: VectorAdapter.hpp:432
Reference getC3()
Returns a mutable reference to component C3 (mapped to element 2 of the wrapped vector).
Definition: VectorAdapter.hpp:423
VectorClosureType & getData()
Returns a reference to the wrapped vector (via its stored closure).
Definition: VectorAdapter.hpp:477
V VectorType
The wrapped 4-element vector type.
Definition: VectorAdapter.hpp:358
ConstReference getC4() const
Returns a const reference to component C4.
Definition: VectorAdapter.hpp:468
ConstReference getC1() const
Returns a const reference to component C1.
Definition: VectorAdapter.hpp:441
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:580
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:382
V::ValueType ValueType
The element value type.
Definition: VectorAdapter.hpp:363
ConstReference getC2() const
Returns a const reference to component C2.
Definition: VectorAdapter.hpp:450
VectorQuaternionAdapter & plusAssign(const QuaternionExpression< E > &e)
Adds the quaternion expression e to this view without intermediate temporary.
Definition: VectorAdapter.hpp:661
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:553
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:707
ConstReference getC3() const
Returns a const reference to component C3.
Definition: VectorAdapter.hpp:459
VectorQuaternionAdapter & operator+=(const QuaternionExpression< E > &e)
Adds the quaternion expression e componentwise to this view.
Definition: VectorAdapter.hpp:539
const VectorClosureType & getData() const
Returns a const reference to the wrapped vector (via its stored closure).
Definition: VectorAdapter.hpp:486
Reference getC1()
Returns a mutable reference to component C1 (mapped to element 0 of the wrapped vector).
Definition: VectorAdapter.hpp:405
SelfType ClosureType
Closure type used when this adapter appears inside another expression.
Definition: VectorAdapter.hpp:392
VectorQuaternionAdapter & operator*=(const QuaternionExpression< E > &e)
Multiplies this view by the quaternion expression e (Hamilton-product semantics).
Definition: VectorAdapter.hpp:593
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:375
VectorQuaternionAdapter & operator=(const VectorQuaternionAdapter &a)
Copies the components of a into this view (writing through to the wrapped vector).
Definition: VectorAdapter.hpp:496
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:523
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:634
VectorQuaternionAdapter(VectorType &v)
Constructs the adapter wrapping the 4-element vector v.
Definition: VectorAdapter.hpp:398
V::ConstReference ConstReference
Constant component reference type.
Definition: VectorAdapter.hpp:368
Reference getC2()
Returns a mutable reference to component C2 (mapped to element 1 of the wrapped vector).
Definition: VectorAdapter.hpp:414
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:607
const SelfType ConstClosureType
Constant closure type used when this adapter appears inside another expression.
Definition: VectorAdapter.hpp:387
void swap(VectorQuaternionAdapter &a)
Swaps the components of this view with those of a.
Definition: VectorAdapter.hpp:684
VectorQuaternionAdapter & minusAssign(const QuaternionExpression< E > &e)
Subtracts the quaternion expression e from this view without intermediate temporary.
Definition: VectorAdapter.hpp:674
VectorQuaternionAdapter & operator=(const QuaternionExpression< E > &e)
Assigns the quaternion expression e to this view (writing through to the wrapped vector).
Definition: VectorAdapter.hpp:509
VectorQuaternionAdapter & operator-=(const QuaternionExpression< E > &e)
Subtracts the quaternion expression e componentwise from this view.
Definition: VectorAdapter.hpp:566
friend void swap(VectorQuaternionAdapter &a1, VectorQuaternionAdapter &a2)
ADL-enabled free-function form of swap().
Definition: VectorAdapter.hpp:695
VectorQuaternionAdapter & operator/=(const QuaternionExpression< E > &e)
Divides this view by the quaternion expression e (Hamilton-quotient semantics).
Definition: VectorAdapter.hpp:620
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 > &e)
Creates a mutable Math::HomogenousCoordsAdapter view of the vector expression e (extends e by an impl...
Definition: VectorAdapter.hpp:801
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:734
Quaternion< typename V::ValueType > Type
The Math::Quaternion specialization used as the temporary quaternion type.
Definition: VectorAdapter.hpp:748
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