27 #ifndef CDPL_MATH_VECTORPROXY_HPP
28 #define CDPL_MATH_VECTORPROXY_HPP
30 #include <type_traits>
68 typedef typename std::conditional<std::is_const<V>::value,
69 typename V::ConstReference,
72 typedef typename std::conditional<std::is_const<V>::value,
73 typename V::ConstClosureType,
97 return data(range(i));
107 return data(range(i));
117 return data[range(i)];
127 return data[range(i)];
192 template <
typename E>
205 template <
typename E>
218 template <
typename E>
231 template <
typename T>
234 vectorAssignScalar<ScalarMultiplicationAssignment>(*
this, t);
244 template <
typename T>
247 vectorAssignScalar<ScalarDivisionAssignment>(*
this, t);
258 template <
typename E>
261 vectorAssignVector<ScalarAssignment>(*
this, e);
271 template <
typename E>
274 vectorAssignVector<ScalarAdditionAssignment>(*
this, e);
284 template <
typename E>
287 vectorAssignVector<ScalarSubtractionAssignment>(*
this, e);
320 template <
typename V>
338 typedef typename std::conditional<std::is_const<V>::value,
339 typename V::ConstReference,
342 typedef typename std::conditional<std::is_const<V>::value,
343 typename V::ConstClosureType,
367 return data(slice(i));
377 return data(slice(i));
387 return data[slice(i)];
397 return data[slice(i)];
471 template <
typename E>
484 template <
typename E>
497 template <
typename E>
510 template <
typename T>
513 vectorAssignScalar<ScalarMultiplicationAssignment>(*
this, t);
523 template <
typename T>
526 vectorAssignScalar<ScalarDivisionAssignment>(*
this, t);
537 template <
typename E>
540 vectorAssignVector<ScalarAssignment>(*
this, e);
550 template <
typename E>
553 vectorAssignVector<ScalarAdditionAssignment>(*
this, e);
563 template <
typename E>
566 vectorAssignVector<ScalarSubtractionAssignment>(*
this, e);
599 template <
typename V>
607 template <
typename V>
615 template <
typename V>
623 template <
typename V>
634 template <
typename E>
648 template <
typename E>
663 template <
typename E>
682 template <
typename E>
700 template <
typename E>
714 template <
typename E>
730 template <
typename E>
751 template <
typename E>
Definition of basic expression types.
Definition of various functors.
Definition of a data type for describing index ranges.
Definition of a data type for describing index slices.
Definition of type traits.
Implementation of vector assignment routines.
SizeType getStart() const
Returns the lower (inclusive) bound.
Definition: Range.hpp:91
bool isEmpty() const
Tells whether the range is empty.
Definition: Range.hpp:118
SizeType getSize() const
Returns the size of the range, .
Definition: Range.hpp:109
SizeType SizeType
The integral size/index type.
Definition: Range.hpp:55
SizeType SizeType
The integral size/index type.
Definition: Slice.hpp:60
SizeType getStart() const
Returns the starting global index.
Definition: Slice.hpp:99
SizeType getSize() const
Returns the number of entries in the slice.
Definition: Slice.hpp:117
DifferenceType getStride() const
Returns the signed step size between consecutive entries.
Definition: Slice.hpp:108
DifferenceType DifferenceType
The signed difference type used for the stride.
Definition: Slice.hpp:62
bool isEmpty() const
Tells whether the slice is empty.
Definition: Slice.hpp:126
CRTP base class for all vector expression types.
Definition: Expression.hpp:66
Vector-expression proxy that views a contiguous half-open subrange of an underlying vector.
Definition: VectorProxy.hpp:52
bool isEmpty() const
Tells whether the view is empty (zero-length range).
Definition: VectorProxy.hpp:152
SizeType getStart() const
Returns the start index of the viewed range within the wrapped vector.
Definition: VectorProxy.hpp:134
Reference operator[](SizeType i)
Returns a mutable reference to the element at index i of the view (alias for operator()).
Definition: VectorProxy.hpp:115
VectorRange & assign(const VectorExpression< E > &e)
Assigns the vector expression e to this view without intermediate temporary (use only when e does not...
Definition: VectorProxy.hpp:259
VectorClosureType & getData()
Returns a reference to the wrapped vector (via its stored closure).
Definition: VectorProxy.hpp:161
Reference operator()(SizeType i)
Returns a mutable reference to the element at index i of the view.
Definition: VectorProxy.hpp:95
friend void swap(VectorRange &r1, VectorRange &r2)
ADL-enabled free-function form of swap().
Definition: VectorProxy.hpp:306
ConstReference operator[](SizeType i) const
Returns a const reference to the element at index i of the view (alias for operator()).
Definition: VectorProxy.hpp:125
VectorRange & operator-=(const VectorExpression< E > &e)
Subtracts the vector expression e componentwise from this view.
Definition: VectorProxy.hpp:219
V VectorType
The wrapped vector type.
Definition: VectorProxy.hpp:58
std::enable_if< IsScalar< T >::value, VectorRange >::type & operator/=(const T &t)
Divides every element of this view by the scalar t.
Definition: VectorProxy.hpp:245
SizeType getSize() const
Returns the size of the view (number of elements covered by the range).
Definition: VectorProxy.hpp:143
VectorRange(VectorType &v, const RangeType &r)
Constructs the proxy viewing the subrange r of v.
Definition: VectorProxy.hpp:87
SelfType ClosureType
Closure type used when this proxy appears inside another expression.
Definition: VectorProxy.hpp:78
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: VectorProxy.hpp:74
const VectorClosureType & getData() const
Returns a const reference to the wrapped vector (via its stored closure).
Definition: VectorProxy.hpp:170
VectorRange & operator=(const VectorRange &r)
Copies the elements of r into this view (writing through to the wrapped vector).
Definition: VectorProxy.hpp:180
V::ConstReference ConstReference
Constant reference type to an element.
Definition: VectorProxy.hpp:66
V::ValueType ValueType
The element value type of the wrapped vector.
Definition: VectorProxy.hpp:64
VectorRange & operator=(const VectorExpression< E > &e)
Assigns the vector expression e to this view (writing through to the wrapped vector).
Definition: VectorProxy.hpp:193
VectorRange & plusAssign(const VectorExpression< E > &e)
Adds the vector expression e to this view without intermediate temporary.
Definition: VectorProxy.hpp:272
V::DifferenceType DifferenceType
The signed difference type used by the wrapped vector.
Definition: VectorProxy.hpp:62
VectorRange & minusAssign(const VectorExpression< E > &e)
Subtracts the vector expression e from this view without intermediate temporary.
Definition: VectorProxy.hpp:285
void swap(VectorRange &r)
Swaps the elements of this view with those of r.
Definition: VectorProxy.hpp:295
std::conditional< std::is_const< V >::value, typename V::ConstReference, typename V::Reference >::type Reference
Mutable reference type (degrades to ConstReference when the wrapped vector is const).
Definition: VectorProxy.hpp:70
Range< SizeType > RangeType
The Math::Range type defining the half-open index subrange.
Definition: VectorProxy.hpp:80
const SelfType ConstClosureType
Constant closure type used when this proxy appears inside another expression.
Definition: VectorProxy.hpp:76
V::SizeType SizeType
The size type used by the wrapped vector.
Definition: VectorProxy.hpp:60
VectorRange & operator+=(const VectorExpression< E > &e)
Adds the vector expression e componentwise to this view.
Definition: VectorProxy.hpp:206
std::enable_if< IsScalar< T >::value, VectorRange >::type & operator*=(const T &t)
Multiplies every element of this view by the scalar t.
Definition: VectorProxy.hpp:232
ConstReference operator()(SizeType i) const
Returns a const reference to the element at index i of the view.
Definition: VectorProxy.hpp:105
Vector-expression proxy that views a strided slice of an underlying vector.
Definition: VectorProxy.hpp:322
VectorSlice & operator=(const VectorExpression< E > &e)
Assigns the vector expression e to this view (writing through to the wrapped vector).
Definition: VectorProxy.hpp:472
ConstReference operator()(SizeType i) const
Returns a const reference to the element at index i of the view.
Definition: VectorProxy.hpp:375
V::DifferenceType DifferenceType
The signed difference type used by the wrapped vector.
Definition: VectorProxy.hpp:332
Slice< SizeType, DifferenceType > SliceType
The Math::Slice type defining the (start, stride, size) selection.
Definition: VectorProxy.hpp:350
ConstReference operator[](SizeType i) const
Returns a const reference to the element at index i of the view (alias for operator()).
Definition: VectorProxy.hpp:395
const VectorClosureType & getData() const
Returns a const reference to the wrapped vector (via its stored closure).
Definition: VectorProxy.hpp:449
Reference operator[](SizeType i)
Returns a mutable reference to the element at index i of the view (alias for operator()).
Definition: VectorProxy.hpp:385
V::ValueType ValueType
The element value type of the wrapped vector.
Definition: VectorProxy.hpp:334
VectorSlice & plusAssign(const VectorExpression< E > &e)
Adds the vector expression e to this view without intermediate temporary.
Definition: VectorProxy.hpp:551
const SelfType ConstClosureType
Constant closure type used when this proxy appears inside another expression.
Definition: VectorProxy.hpp:346
VectorSlice & operator+=(const VectorExpression< E > &e)
Adds the vector expression e componentwise to this view.
Definition: VectorProxy.hpp:485
std::enable_if< IsScalar< T >::value, VectorSlice >::type & operator*=(const T &t)
Multiplies every element of this view by the scalar t.
Definition: VectorProxy.hpp:511
SizeType getSize() const
Returns the size of the view (number of elements covered by the slice).
Definition: VectorProxy.hpp:422
Reference operator()(SizeType i)
Returns a mutable reference to the element at index i of the view.
Definition: VectorProxy.hpp:365
std::conditional< std::is_const< V >::value, typename V::ConstReference, typename V::Reference >::type Reference
Mutable reference type (degrades to ConstReference when the wrapped vector is const).
Definition: VectorProxy.hpp:340
bool isEmpty() const
Tells whether the view is empty (zero-length slice).
Definition: VectorProxy.hpp:431
SizeType getStart() const
Returns the start index of the slice within the wrapped vector.
Definition: VectorProxy.hpp:404
DifferenceType getStride() const
Returns the stride of the slice (step between successive viewed elements).
Definition: VectorProxy.hpp:413
V VectorType
The wrapped vector type.
Definition: VectorProxy.hpp:328
std::enable_if< IsScalar< T >::value, VectorSlice >::type & operator/=(const T &t)
Divides every element of this view by the scalar t.
Definition: VectorProxy.hpp:524
friend void swap(VectorSlice &s1, VectorSlice &s2)
ADL-enabled free-function form of swap().
Definition: VectorProxy.hpp:585
void swap(VectorSlice &s)
Swaps the elements of this view with those of s.
Definition: VectorProxy.hpp:574
VectorClosureType & getData()
Returns a reference to the wrapped vector (via its stored closure).
Definition: VectorProxy.hpp:440
V::SizeType SizeType
The size type used by the wrapped vector.
Definition: VectorProxy.hpp:330
V::ConstReference ConstReference
Constant reference type to an element.
Definition: VectorProxy.hpp:336
VectorSlice & minusAssign(const VectorExpression< E > &e)
Subtracts the vector expression e from this view without intermediate temporary.
Definition: VectorProxy.hpp:564
VectorSlice(VectorType &v, const SliceType &s)
Constructs the proxy viewing the slice s of v.
Definition: VectorProxy.hpp:357
VectorSlice & operator=(const VectorSlice &s)
Copies the elements of s into this view (writing through to the wrapped vector).
Definition: VectorProxy.hpp:459
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: VectorProxy.hpp:344
VectorSlice & assign(const VectorExpression< E > &e)
Assigns the vector expression e to this view without intermediate temporary (use only when e does not...
Definition: VectorProxy.hpp:538
VectorSlice & operator-=(const VectorExpression< E > &e)
Subtracts the vector expression e componentwise from this view.
Definition: VectorProxy.hpp:498
SelfType ClosureType
Closure type used when this proxy appears inside another expression.
Definition: VectorProxy.hpp:348
constexpr unsigned int V
Specifies Vanadium.
Definition: AtomType.hpp:177
constexpr unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
constexpr unsigned int r
Specifies that the stereocenter has r configuration.
Definition: CIPDescriptor.hpp:76
constexpr unsigned int s
Specifies that the stereocenter has s configuration.
Definition: CIPDescriptor.hpp:81
MatrixSlice< E > slice(MatrixExpression< E > &e, const typename MatrixSlice< E >::SliceType &s1, const typename MatrixSlice< E >::SliceType &s2)
Returns a mutable matrix slice proxy viewing the strided rectangular slice (s1, s2) of e.
Definition: MatrixProxy.hpp:1368
void vectorSwap(V &v, VectorExpression< E > &e)
Swaps the elements of two equally sized vector expressions element by element.
Definition: VectorAssignment.hpp:97
MatrixRange< E > range(MatrixExpression< E > &e, const typename MatrixRange< E >::RangeType &r1, const typename MatrixRange< E >::RangeType &r2)
Returns a mutable matrix range proxy viewing rows in r1 and columns in r2 of e.
Definition: MatrixProxy.hpp:1288
The namespace of the Chemical Data Processing Library.
Selects a concrete temporary vector type compatible with the vector expression V.
Definition: TypeTraits.hpp:301
V::VectorTemporaryType Type
The concrete temporary vector type compatible with the vector expression V.
Definition: TypeTraits.hpp:304