27 #ifndef CDPL_MATH_MATRIXADAPTER_HPP
28 #define CDPL_MATH_MATRIXADAPTER_HPP
30 #include <type_traits>
58 static typename M::ConstReference
get(
const M&
m,
typename M::SizeType i,
typename M::SizeType j)
61 return m.getData()(i, j);
80 static typename M::ConstReference
get(
const M&
m,
typename M::SizeType i,
typename M::SizeType j)
86 return m.getData()(i, j);
104 template <
typename M>
105 static typename M::ConstReference
get(
const M&
m,
typename M::SizeType i,
typename M::SizeType j)
108 return m.getData()(i, j);
126 template <
typename M>
127 static typename M::ConstReference
get(
const M&
m,
typename M::SizeType i,
typename M::SizeType j)
133 return m.getData()(i, j);
144 template <
typename M,
typename Tri>
169 typedef typename std::conditional<std::is_const<M>::value,
170 typename M::ConstReference,
173 typedef typename std::conditional<std::is_const<M>::value,
174 typename M::ConstClosureType,
199 return TriangularType::template get<SelfType>(*
this, i, j);
208 return data.getSize1();
217 return data.getSize2();
244 return (data.getSize1() == 0 || data.getSize2() == 0);
253 template <
typename M,
typename Tri>
256 template <
typename M,
typename Tri>
264 template <
typename M,
typename Tri>
273 template <
typename M,
typename Tri>
282 template <
typename M,
typename Tri>
291 template <
typename M,
typename Tri>
302 template <
typename Tri,
typename E>
316 template <
typename Tri,
typename E>
317 TriangularAdapter<const E, Tri>
Definition of basic expression types.
Definition of type traits.
CRTP base class for all matrix expression types.
Definition: Expression.hpp:104
Matrix expression that exposes only the triangular part of an underlying matrix M selected by the pol...
Definition: MatrixAdapter.hpp:146
Range< SizeType > RangeType
The Math::Range type used to address sub-ranges.
Definition: MatrixAdapter.hpp:181
const SelfType ConstClosureType
Constant closure type used when this adapter appears inside another expression.
Definition: MatrixAdapter.hpp:177
M MatrixType
The wrapped matrix type.
Definition: MatrixAdapter.hpp:157
M::DifferenceType DifferenceType
The signed difference type used by the underlying matrix.
Definition: MatrixAdapter.hpp:163
M::ValueType ValueType
The element value type of the underlying matrix.
Definition: MatrixAdapter.hpp:165
SizeType getSize2() const
Returns the number of columns of the wrapped matrix.
Definition: MatrixAdapter.hpp:215
MatrixClosureType & getData()
Returns a reference to the wrapped matrix (via its stored closure).
Definition: MatrixAdapter.hpp:224
M::SizeType SizeType
The size type used by the underlying matrix.
Definition: MatrixAdapter.hpp:161
bool isEmpty() const
Tells whether the wrapped matrix is empty (zero rows or zero columns).
Definition: MatrixAdapter.hpp:242
M::ConstReference ConstReference
Constant reference type to an element of the underlying matrix.
Definition: MatrixAdapter.hpp:167
SelfType ClosureType
Closure type used when this adapter appears inside another expression.
Definition: MatrixAdapter.hpp:179
TriangularAdapter(MatrixType &m)
Constructs the adapter wrapping m.
Definition: MatrixAdapter.hpp:187
ConstReference operator()(SizeType i, SizeType j) const
Returns the value of element (i, j) as seen through the triangular policy (off-policy entries return ...
Definition: MatrixAdapter.hpp:197
Tri TriangularType
The triangular-view selection policy.
Definition: MatrixAdapter.hpp:159
const MatrixClosureType & getData() const
Returns a const reference to the wrapped matrix (via its stored closure).
Definition: MatrixAdapter.hpp:233
std::conditional< std::is_const< M >::value, typename M::ConstReference, typename M::Reference >::type Reference
Mutable reference type (degrades to ConstReference when the wrapped matrix is const).
Definition: MatrixAdapter.hpp:171
std::conditional< std::is_const< M >::value, typename M::ConstClosureType, typename M::ClosureType >::type MatrixClosureType
Closure type used to store the wrapped matrix internally (mutable or const flavor).
Definition: MatrixAdapter.hpp:175
SizeType getSize1() const
Returns the number of rows of the wrapped matrix.
Definition: MatrixAdapter.hpp:206
constexpr unsigned int M
Generic type that covers any element that is a metal.
Definition: AtomType.hpp:657
constexpr unsigned int m
Specifies that the stereocenter has m configuration.
Definition: CIPDescriptor.hpp:116
TriangularAdapter< E, Tri > triang(MatrixExpression< E > &e)
Creates a Math::TriangularAdapter view of the matrix expression e using the triangular policy Tri.
Definition: MatrixAdapter.hpp:304
The namespace of the Chemical Data Processing Library.
Tag selecting the lower-triangular view (entries strictly above the diagonal read as zero) for Math::...
Definition: MatrixAdapter.hpp:47
static M::ConstReference get(const M &m, typename M::SizeType i, typename M::SizeType j)
Returns element (i, j) of m under the lower-triangular policy (zero above the diagonal).
Definition: MatrixAdapter.hpp:58
Selects a concrete temporary matrix type compatible with the matrix expression M.
Definition: TypeTraits.hpp:313
Tag selecting the unit-lower-triangular view (zero above the diagonal, one on the diagonal) for Math:...
Definition: MatrixAdapter.hpp:69
static M::ConstReference get(const M &m, typename M::SizeType i, typename M::SizeType j)
Returns element (i, j) of m under the unit-lower-triangular policy (one on the diagonal,...
Definition: MatrixAdapter.hpp:80
Tag selecting the unit-upper-triangular view (zero below the diagonal, one on the diagonal) for Math:...
Definition: MatrixAdapter.hpp:116
static M::ConstReference get(const M &m, typename M::SizeType i, typename M::SizeType j)
Returns element (i, j) of m under the unit-upper-triangular policy (one on the diagonal,...
Definition: MatrixAdapter.hpp:127
Tag selecting the upper-triangular view (entries strictly below the diagonal read as zero) for Math::...
Definition: MatrixAdapter.hpp:94
static M::ConstReference get(const M &m, typename M::SizeType i, typename M::SizeType j)
Returns element (i, j) of m under the upper-triangular policy (zero below the diagonal).
Definition: MatrixAdapter.hpp:105
Selects a concrete temporary vector type compatible with the vector expression V.
Definition: TypeTraits.hpp:301