27 #ifndef CDPL_MATH_SLICE_HPP
28 #define CDPL_MATH_SLICE_HPP
52 template <
typename S,
typename D>
68 start(0), stride(0), size(0) {}
78 start(start), stride(stride), size(size)
92 return (start + i * stride);
138 return (start ==
s.start && stride ==
s.stride && size ==
s.size);
160 std::swap(start,
s.start);
161 std::swap(stride,
s.stride);
162 std::swap(size,
s.size);
188 inline Slice<std::size_t, std::ptrdiff_t>
189 slice(std::size_t start, std::ptrdiff_t stride, std::size_t size)
Definition of exception classes.
Definition of various preprocessor macros for error checking.
#define CDPL_MATH_CHECK(expr, msg, e)
Throws the exception e with message msg when the boolean expression expr evaluates to false.
Definition: Check.hpp:47
Thrown to indicate that an index is out of range.
Definition: Base/Exceptions.hpp:152
Thrown to indicate that a value is out of range.
Definition: Base/Exceptions.hpp:114
Index slice ( ) used for strided slicing of vector and matrix expressions.
Definition: Slice.hpp:54
SizeType operator()(SizeType i) const
Maps the local position i to the global index .
Definition: Slice.hpp:89
friend void swap(Slice &s1, Slice &s2)
Free-function swap overload.
Definition: Slice.hpp:170
S SizeType
The integral size/index type.
Definition: Slice.hpp:60
bool operator!=(const Slice &s) const
Inequality comparison.
Definition: Slice.hpp:146
Slice()
Constructs an empty slice ( ).
Definition: Slice.hpp:67
SizeType getStart() const
Returns the starting global index.
Definition: Slice.hpp:99
bool operator==(const Slice &s) const
Equality comparison.
Definition: Slice.hpp:136
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
Slice(SizeType start, DifferenceType stride, SizeType size)
Constructs the slice (start, stride, size).
Definition: Slice.hpp:77
D DifferenceType
The signed difference type used for the stride.
Definition: Slice.hpp:62
void swap(Slice &s)
Swaps the contents of *this and s.
Definition: Slice.hpp:155
bool isEmpty() const
Tells whether the slice is empty.
Definition: Slice.hpp:126
constexpr unsigned int S
Specifies that the atom has S configuration.
Definition: AtomConfiguration.hpp:63
constexpr unsigned int D
Specifies Hydrogen (Deuterium).
Definition: AtomType.hpp:62
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
The namespace of the Chemical Data Processing Library.