Chemical Data Processing Library C++ API - Version 1.4.0
Public Types | Public Member Functions | Friends | List of all members
CDPL::Math::QuaternionVectorAdapter< Q > Class Template Reference

View adapter that exposes a quaternion as a 4-element vector expression (indices map to the components C1, C2, C3, C4). More...

#include <QuaternionAdapter.hpp>

+ Inheritance diagram for CDPL::Math::QuaternionVectorAdapter< Q >:

Public Types

typedef Q QuaternionType
 The wrapped quaternion type. More...
 
typedef std::size_t SizeType
 The size type (std::size_t). More...
 
typedef std::ptrdiff_t DifferenceType
 The signed difference type (std::ptrdiff_t). More...
 
typedef Q::ValueType ValueType
 The element value type of the wrapped quaternion. More...
 
typedef Q::ConstReference ConstReference
 Constant reference type to an element of the wrapped quaternion. More...
 
typedef std::conditional< std::is_const< Q >::value, typename Q::ConstReference, typename Q::Reference >::type Reference
 Mutable reference type (degrades to ConstReference when the wrapped quaternion is const). More...
 
typedef std::conditional< std::is_const< Q >::value, typename Q::ConstClosureType, typename Q::ClosureType >::type QuaternionClosureType
 Closure type used to store the wrapped quaternion internally (mutable or const flavor). More...
 
typedef const SelfType ConstClosureType
 Constant closure type used when this adapter appears inside another expression. More...
 
typedef SelfType ClosureType
 Closure type used when this adapter appears inside another expression. More...
 
- Public Types inherited from CDPL::Math::VectorExpression< QuaternionVectorAdapter< Q > >
typedef QuaternionVectorAdapter< Q > ExpressionType
 The derived vector expression type. More...
 
- Public Types inherited from CDPL::Math::Expression< E >
typedef E ExpressionType
 The derived expression type (made available to expression-template machinery). More...
 

Public Member Functions

 QuaternionVectorAdapter (QuaternionType &q)
 Constructs the adapter wrapping the quaternion q. More...
 
Reference operator() (SizeType i)
 Returns a mutable reference to the quaternion component at index i. More...
 
ConstReference operator() (SizeType i) const
 Returns a const reference to the quaternion component at index i. More...
 
Reference operator[] (SizeType i)
 Returns a mutable reference to the quaternion component at index i (alias for operator()). More...
 
ConstReference operator[] (SizeType i) const
 Returns a const reference to the quaternion component at index i (alias for operator()). More...
 
SizeType getSize () const
 Returns the dimensionality of the view (always 4). More...
 
bool isEmpty () const
 Tells whether the view is empty (always false; the view is fixed-size with 4 components). More...
 
QuaternionClosureTypegetData ()
 Returns a reference to the wrapped quaternion (via its stored closure). More...
 
const QuaternionClosureTypegetData () const
 Returns a const reference to the wrapped quaternion (via its stored closure). More...
 
QuaternionVectorAdapteroperator= (const QuaternionVectorAdapter &a)
 Copies the components of a into this view (writing through to the wrapped quaternion). More...
 
template<typename E >
QuaternionVectorAdapteroperator= (const VectorExpression< E > &e)
 Assigns the vector expression e to this view (writing through to the wrapped quaternion). More...
 
template<typename E >
QuaternionVectorAdapteroperator+= (const VectorExpression< E > &e)
 Adds the vector expression e componentwise to this view. More...
 
template<typename E >
QuaternionVectorAdapteroperator-= (const VectorExpression< E > &e)
 Subtracts the vector expression e componentwise from this view. More...
 
template<typename T >
std::enable_if< IsScalar< T >::value, QuaternionVectorAdapter >::type & operator*= (const T &t)
 Multiplies every component of this view by the scalar t. More...
 
template<typename T >
std::enable_if< IsScalar< T >::value, QuaternionVectorAdapter >::type & operator/= (const T &t)
 Divides every component of this view by the scalar t. More...
 
template<typename E >
QuaternionVectorAdapterassign (const VectorExpression< E > &e)
 Assigns the vector expression e to this view without intermediate temporary (use only when e does not alias the wrapped quaternion). More...
 
template<typename E >
QuaternionVectorAdapterplusAssign (const VectorExpression< E > &e)
 Adds the vector expression e to this view without intermediate temporary. More...
 
template<typename E >
QuaternionVectorAdapterminusAssign (const VectorExpression< E > &e)
 Subtracts the vector expression e from this view without intermediate temporary. More...
 
void swap (QuaternionVectorAdapter &a)
 Swaps the components of this view with those of a. More...
 
- Public Member Functions inherited from CDPL::Math::VectorExpression< QuaternionVectorAdapter< Q > >
const ExpressionTypeoperator() () const
 Returns a const reference to the derived vector expression. More...
 
ExpressionTypeoperator() ()
 Returns a reference to the derived vector expression. More...
 

Friends

void swap (QuaternionVectorAdapter &a1, QuaternionVectorAdapter &a2)
 ADL-enabled free-function form of swap(). More...
 

Additional Inherited Members

- Protected Member Functions inherited from CDPL::Math::VectorExpression< QuaternionVectorAdapter< Q > >
 VectorExpression ()
 
 ~VectorExpression ()
 
- Protected Member Functions inherited from CDPL::Math::Expression< E >
 Expression ()
 
 ~Expression ()
 

Detailed Description

template<typename Q>
class CDPL::Math::QuaternionVectorAdapter< Q >

View adapter that exposes a quaternion as a 4-element vector expression (indices map to the components C1, C2, C3, C4).

Template Parameters
QThe wrapped quaternion type.

Member Typedef Documentation

◆ QuaternionType

template<typename Q >
typedef Q CDPL::Math::QuaternionVectorAdapter< Q >::QuaternionType

The wrapped quaternion type.

◆ SizeType

template<typename Q >
typedef std::size_t CDPL::Math::QuaternionVectorAdapter< Q >::SizeType

The size type (std::size_t).

◆ DifferenceType

template<typename Q >
typedef std::ptrdiff_t CDPL::Math::QuaternionVectorAdapter< Q >::DifferenceType

The signed difference type (std::ptrdiff_t).

◆ ValueType

template<typename Q >
typedef Q::ValueType CDPL::Math::QuaternionVectorAdapter< Q >::ValueType

The element value type of the wrapped quaternion.

◆ ConstReference

template<typename Q >
typedef Q::ConstReference CDPL::Math::QuaternionVectorAdapter< Q >::ConstReference

Constant reference type to an element of the wrapped quaternion.

◆ Reference

template<typename Q >
typedef std::conditional<std::is_const<Q>::value, typename Q::ConstReference, typename Q::Reference>::type CDPL::Math::QuaternionVectorAdapter< Q >::Reference

Mutable reference type (degrades to ConstReference when the wrapped quaternion is const).

◆ QuaternionClosureType

template<typename Q >
typedef std::conditional<std::is_const<Q>::value, typename Q::ConstClosureType, typename Q::ClosureType>::type CDPL::Math::QuaternionVectorAdapter< Q >::QuaternionClosureType

Closure type used to store the wrapped quaternion internally (mutable or const flavor).

◆ ConstClosureType

template<typename Q >
typedef const SelfType CDPL::Math::QuaternionVectorAdapter< Q >::ConstClosureType

Constant closure type used when this adapter appears inside another expression.

◆ ClosureType

template<typename Q >
typedef SelfType CDPL::Math::QuaternionVectorAdapter< Q >::ClosureType

Closure type used when this adapter appears inside another expression.

Constructor & Destructor Documentation

◆ QuaternionVectorAdapter()

template<typename Q >
CDPL::Math::QuaternionVectorAdapter< Q >::QuaternionVectorAdapter ( QuaternionType q)
inlineexplicit

Constructs the adapter wrapping the quaternion q.

Parameters
qThe quaternion to be viewed as a 4-element vector.

Member Function Documentation

◆ operator()() [1/2]

template<typename Q >
Reference CDPL::Math::QuaternionVectorAdapter< Q >::operator() ( SizeType  i)
inline

Returns a mutable reference to the quaternion component at index i.

Parameters
iThe zero-based component index (0 = C1, 1 = C2, 2 = C3, 3 = C4).
Returns
A mutable reference to the component.
Exceptions
Base::IndexErrorif i is not in the range [0, 3].

◆ operator()() [2/2]

template<typename Q >
ConstReference CDPL::Math::QuaternionVectorAdapter< Q >::operator() ( SizeType  i) const
inline

Returns a const reference to the quaternion component at index i.

Parameters
iThe zero-based component index (0 = C1, 1 = C2, 2 = C3, 3 = C4).
Returns
A const reference to the component.
Exceptions
Base::IndexErrorif i is not in the range [0, 3].

◆ operator[]() [1/2]

template<typename Q >
Reference CDPL::Math::QuaternionVectorAdapter< Q >::operator[] ( SizeType  i)
inline

Returns a mutable reference to the quaternion component at index i (alias for operator()).

Parameters
iThe zero-based component index.
Returns
A mutable reference to the component.
Exceptions
Base::IndexErrorif i is not in the range [0, 3].

◆ operator[]() [2/2]

template<typename Q >
ConstReference CDPL::Math::QuaternionVectorAdapter< Q >::operator[] ( SizeType  i) const
inline

Returns a const reference to the quaternion component at index i (alias for operator()).

Parameters
iThe zero-based component index.
Returns
A const reference to the component.
Exceptions
Base::IndexErrorif i is not in the range [0, 3].

◆ getSize()

template<typename Q >
SizeType CDPL::Math::QuaternionVectorAdapter< Q >::getSize ( ) const
inline

Returns the dimensionality of the view (always 4).

Returns
The size value 4.

◆ isEmpty()

template<typename Q >
bool CDPL::Math::QuaternionVectorAdapter< Q >::isEmpty ( ) const
inline

Tells whether the view is empty (always false; the view is fixed-size with 4 components).

Returns
false.

◆ getData() [1/2]

template<typename Q >
QuaternionClosureType& CDPL::Math::QuaternionVectorAdapter< Q >::getData ( )
inline

Returns a reference to the wrapped quaternion (via its stored closure).

Returns
A reference to the wrapped quaternion closure.

◆ getData() [2/2]

template<typename Q >
const QuaternionClosureType& CDPL::Math::QuaternionVectorAdapter< Q >::getData ( ) const
inline

Returns a const reference to the wrapped quaternion (via its stored closure).

Returns
A const reference to the wrapped quaternion closure.

◆ operator=() [1/2]

template<typename Q >
QuaternionVectorAdapter& CDPL::Math::QuaternionVectorAdapter< Q >::operator= ( const QuaternionVectorAdapter< Q > &  a)
inline

Copies the components of a into this view (writing through to the wrapped quaternion).

Parameters
aThe source adapter.
Returns
A reference to itself.

◆ operator=() [2/2]

template<typename Q >
template<typename E >
QuaternionVectorAdapter& CDPL::Math::QuaternionVectorAdapter< Q >::operator= ( const VectorExpression< E > &  e)
inline

Assigns the vector expression e to this view (writing through to the wrapped quaternion).

Template Parameters
EThe source vector expression type.
Parameters
eThe source vector expression.
Returns
A reference to itself.

◆ operator+=()

template<typename Q >
template<typename E >
QuaternionVectorAdapter& CDPL::Math::QuaternionVectorAdapter< Q >::operator+= ( const VectorExpression< E > &  e)
inline

Adds the vector expression e componentwise to this view.

Template Parameters
EThe source vector expression type.
Parameters
eThe vector expression to add.
Returns
A reference to itself.

◆ operator-=()

template<typename Q >
template<typename E >
QuaternionVectorAdapter& CDPL::Math::QuaternionVectorAdapter< Q >::operator-= ( const VectorExpression< E > &  e)
inline

Subtracts the vector expression e componentwise from this view.

Template Parameters
EThe source vector expression type.
Parameters
eThe vector expression to subtract.
Returns
A reference to itself.

◆ operator*=()

template<typename Q >
template<typename T >
std::enable_if<IsScalar<T>::value, QuaternionVectorAdapter>::type& CDPL::Math::QuaternionVectorAdapter< Q >::operator*= ( const T &  t)
inline

Multiplies every component of this view by the scalar t.

Template Parameters
TThe scalar type.
Parameters
tThe scalar multiplier.
Returns
A reference to itself.

◆ operator/=()

template<typename Q >
template<typename T >
std::enable_if<IsScalar<T>::value, QuaternionVectorAdapter>::type& CDPL::Math::QuaternionVectorAdapter< Q >::operator/= ( const T &  t)
inline

Divides every component of this view by the scalar t.

Template Parameters
TThe scalar type.
Parameters
tThe scalar divisor.
Returns
A reference to itself.

◆ assign()

template<typename Q >
template<typename E >
QuaternionVectorAdapter& CDPL::Math::QuaternionVectorAdapter< Q >::assign ( const VectorExpression< E > &  e)
inline

Assigns the vector expression e to this view without intermediate temporary (use only when e does not alias the wrapped quaternion).

Template Parameters
EThe source vector expression type.
Parameters
eThe source vector expression.
Returns
A reference to itself.

◆ plusAssign()

template<typename Q >
template<typename E >
QuaternionVectorAdapter& CDPL::Math::QuaternionVectorAdapter< Q >::plusAssign ( const VectorExpression< E > &  e)
inline

Adds the vector expression e to this view without intermediate temporary.

Template Parameters
EThe source vector expression type.
Parameters
eThe source vector expression.
Returns
A reference to itself.

◆ minusAssign()

template<typename Q >
template<typename E >
QuaternionVectorAdapter& CDPL::Math::QuaternionVectorAdapter< Q >::minusAssign ( const VectorExpression< E > &  e)
inline

Subtracts the vector expression e from this view without intermediate temporary.

Template Parameters
EThe source vector expression type.
Parameters
eThe source vector expression.
Returns
A reference to itself.

◆ swap()

template<typename Q >
void CDPL::Math::QuaternionVectorAdapter< Q >::swap ( QuaternionVectorAdapter< Q > &  a)
inline

Swaps the components of this view with those of a.

Parameters
aThe adapter to swap with.

Friends And Related Function Documentation

◆ swap

template<typename Q >
void swap ( QuaternionVectorAdapter< Q > &  a1,
QuaternionVectorAdapter< Q > &  a2 
)
friend

ADL-enabled free-function form of swap().

Parameters
a1The first adapter.
a2The second adapter.

The documentation for this class was generated from the following file: