27 #ifndef CDPL_MATH_VECTORPROXY_HPP
28 #define CDPL_MATH_VECTORPROXY_HPP
30 #include <type_traits>
85 typedef typename std::conditional<std::is_const<V>::value,
86 typename V::ConstReference,
92 typedef typename std::conditional<std::is_const<V>::value,
93 typename V::ConstClosureType,
126 return data(range(i));
136 return data(range(i));
146 return data[range(i)];
156 return data[range(i)];
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);
287 template <
typename E>
290 vectorAssignVector<ScalarAssignment>(*
this, e);
300 template <
typename E>
303 vectorAssignVector<ScalarAdditionAssignment>(*
this, e);
313 template <
typename E>
316 vectorAssignVector<ScalarSubtractionAssignment>(*
this, e);
349 template <
typename V>
384 typedef typename std::conditional<std::is_const<V>::value,
385 typename V::ConstReference,
391 typedef typename std::conditional<std::is_const<V>::value,
392 typename V::ConstClosureType,
425 return data(slice(i));
435 return data(slice(i));
445 return data[slice(i)];
455 return data[slice(i)];
529 template <
typename E>
542 template <
typename E>
555 template <
typename E>
568 template <
typename T>
571 vectorAssignScalar<ScalarMultiplicationAssignment>(*
this, t);
581 template <
typename T>
584 vectorAssignScalar<ScalarDivisionAssignment>(*
this, t);
595 template <
typename E>
598 vectorAssignVector<ScalarAssignment>(*
this, e);
608 template <
typename E>
611 vectorAssignVector<ScalarAdditionAssignment>(*
this, e);
621 template <
typename E>
624 vectorAssignVector<ScalarSubtractionAssignment>(*
this, e);
657 template <
typename V>
665 template <
typename V>
673 template <
typename V>
681 template <
typename V>
692 template <
typename E>
706 template <
typename E>
721 template <
typename E>
740 template <
typename E>
758 template <
typename E>
772 template <
typename E>
788 template <
typename E>
809 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:93
bool isEmpty() const
Tells whether the range is empty.
Definition: Range.hpp:120
SizeType getSize() const
Returns the size of the range.
Definition: Range.hpp:111
SizeType SizeType
The integral size/index type.
Definition: Range.hpp:57
SizeType SizeType
The integral size/index type.
Definition: Slice.hpp:62
SizeType getStart() const
Returns the starting global index.
Definition: Slice.hpp:104
SizeType getSize() const
Returns the number of entries in the slice.
Definition: Slice.hpp:122
DifferenceType getStride() const
Returns the signed step size between consecutive entries.
Definition: Slice.hpp:113
DifferenceType DifferenceType
The signed difference type used for the stride.
Definition: Slice.hpp:67
bool isEmpty() const
Tells whether the slice is empty.
Definition: Slice.hpp:131
CRTP base class of all vector expression types.
Definition: Expression.hpp:68
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:181
SizeType getStart() const
Returns the start index of the viewed range within the wrapped vector.
Definition: VectorProxy.hpp:163
Reference operator[](SizeType i)
Returns a mutable reference to the element at index i of the view.
Definition: VectorProxy.hpp:144
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:288
VectorClosureType & getData()
Returns a reference to the wrapped vector (via its stored closure).
Definition: VectorProxy.hpp:190
Reference operator()(SizeType i)
Returns a mutable reference to the element at index i of the view.
Definition: VectorProxy.hpp:124
friend void swap(VectorRange &r1, VectorRange &r2)
ADL-enabled free-function form of swap().
Definition: VectorProxy.hpp:335
ConstReference operator[](SizeType i) const
Returns a const reference to the element at index i of the view.
Definition: VectorProxy.hpp:154
VectorRange & operator-=(const VectorExpression< E > &e)
Subtracts the vector expression e componentwise from this view.
Definition: VectorProxy.hpp:248
V VectorType
The wrapped vector type.
Definition: VectorProxy.hpp:60
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:274
SizeType getSize() const
Returns the size of the view (number of elements covered by the range).
Definition: VectorProxy.hpp:172
VectorRange(VectorType &v, const RangeType &r)
Constructs the proxy viewing the subrange r of v.
Definition: VectorProxy.hpp:116
SelfType ClosureType
Closure type used when this proxy appears inside another expression.
Definition: VectorProxy.hpp:104
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:94
const VectorClosureType & getData() const
Returns a const reference to the wrapped vector (via its stored closure).
Definition: VectorProxy.hpp:199
VectorRange & operator=(const VectorRange &r)
Copies the elements of r into this view (writing through to the wrapped vector).
Definition: VectorProxy.hpp:209
V::ConstReference ConstReference
Constant element reference type.
Definition: VectorProxy.hpp:80
V::ValueType ValueType
The element value type of the wrapped vector.
Definition: VectorProxy.hpp:75
VectorRange & operator=(const VectorExpression< E > &e)
Assigns the vector expression e to this view (writing through to the wrapped vector).
Definition: VectorProxy.hpp:222
VectorRange & plusAssign(const VectorExpression< E > &e)
Adds the vector expression e to this view without intermediate temporary.
Definition: VectorProxy.hpp:301
V::DifferenceType DifferenceType
The signed difference type used by the wrapped vector.
Definition: VectorProxy.hpp:70
VectorRange & minusAssign(const VectorExpression< E > &e)
Subtracts the vector expression e from this view without intermediate temporary.
Definition: VectorProxy.hpp:314
void swap(VectorRange &r)
Swaps the elements of this view with those of r.
Definition: VectorProxy.hpp:324
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: VectorProxy.hpp:87
Range< SizeType > RangeType
The Math::Range type defining the half-open index subrange.
Definition: VectorProxy.hpp:109
const SelfType ConstClosureType
Constant closure type used when this proxy appears inside another expression.
Definition: VectorProxy.hpp:99
V::SizeType SizeType
The size type used by the wrapped vector.
Definition: VectorProxy.hpp:65
VectorRange & operator+=(const VectorExpression< E > &e)
Adds the vector expression e componentwise to this view.
Definition: VectorProxy.hpp:235
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:261
ConstReference operator()(SizeType i) const
Returns a const reference to the element at index i of the view.
Definition: VectorProxy.hpp:134
Vector expression proxy that views a strided slice of an underlying vector.
Definition: VectorProxy.hpp:351
VectorSlice & operator=(const VectorExpression< E > &e)
Assigns the vector expression e to this view (writing through to the wrapped vector).
Definition: VectorProxy.hpp:530
ConstReference operator()(SizeType i) const
Returns a const reference to the element at index i of the view.
Definition: VectorProxy.hpp:433
V::DifferenceType DifferenceType
The signed difference type used by the wrapped vector.
Definition: VectorProxy.hpp:369
Slice< SizeType, DifferenceType > SliceType
The Math::Slice type defining the (start, stride, size) selection.
Definition: VectorProxy.hpp:408
ConstReference operator[](SizeType i) const
Returns a const reference to the element at index i of the view.
Definition: VectorProxy.hpp:453
const VectorClosureType & getData() const
Returns a const reference to the wrapped vector (via its stored closure).
Definition: VectorProxy.hpp:507
Reference operator[](SizeType i)
Returns a mutable reference to the element at index i of the view.
Definition: VectorProxy.hpp:443
V::ValueType ValueType
The element value type of the wrapped vector.
Definition: VectorProxy.hpp:374
VectorSlice & plusAssign(const VectorExpression< E > &e)
Adds the vector expression e to this view without intermediate temporary.
Definition: VectorProxy.hpp:609
const SelfType ConstClosureType
Constant closure type used when this proxy appears inside another expression.
Definition: VectorProxy.hpp:398
VectorSlice & operator+=(const VectorExpression< E > &e)
Adds the vector expression e componentwise to this view.
Definition: VectorProxy.hpp:543
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:569
SizeType getSize() const
Returns the size of the view (number of elements covered by the slice).
Definition: VectorProxy.hpp:480
Reference operator()(SizeType i)
Returns a mutable reference to the element at index i of the view.
Definition: VectorProxy.hpp:423
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: VectorProxy.hpp:386
bool isEmpty() const
Tells whether the view is empty (zero-length slice).
Definition: VectorProxy.hpp:489
SizeType getStart() const
Returns the start index of the slice within the wrapped vector.
Definition: VectorProxy.hpp:462
DifferenceType getStride() const
Returns the stride of the slice (step between successive viewed elements).
Definition: VectorProxy.hpp:471
V VectorType
The wrapped vector type.
Definition: VectorProxy.hpp:359
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:582
friend void swap(VectorSlice &s1, VectorSlice &s2)
ADL-enabled free-function form of swap().
Definition: VectorProxy.hpp:643
void swap(VectorSlice &s)
Swaps the elements of this view with those of s.
Definition: VectorProxy.hpp:632
VectorClosureType & getData()
Returns a reference to the wrapped vector (via its stored closure).
Definition: VectorProxy.hpp:498
V::SizeType SizeType
The size type used by the wrapped vector.
Definition: VectorProxy.hpp:364
V::ConstReference ConstReference
Constant element reference type.
Definition: VectorProxy.hpp:379
VectorSlice & minusAssign(const VectorExpression< E > &e)
Subtracts the vector expression e from this view without intermediate temporary.
Definition: VectorProxy.hpp:622
VectorSlice(VectorType &v, const SliceType &s)
Constructs the proxy viewing the slice s of v.
Definition: VectorProxy.hpp:415
VectorSlice & operator=(const VectorSlice &s)
Copies the elements of s into this view (writing through to the wrapped vector).
Definition: VectorProxy.hpp:517
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:393
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:596
VectorSlice & operator-=(const VectorExpression< E > &e)
Subtracts the vector expression e componentwise from this view.
Definition: VectorProxy.hpp:556
SelfType ClosureType
Closure type used when this proxy appears inside another expression.
Definition: VectorProxy.hpp:403
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:1509
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:1429
The namespace of the Chemical Data Processing Library.
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