10#ifndef EIGEN_REPLICATE_H
11#define EIGEN_REPLICATE_H
14#include "./InternalHeaderCheck.h"
19template <
typename MatrixType,
int RowFactor,
int ColFactor>
20struct traits<Replicate<MatrixType, RowFactor, ColFactor> > : traits<MatrixType> {
21 typedef typename MatrixType::Scalar Scalar;
22 typedef typename traits<MatrixType>::StorageKind StorageKind;
23 typedef typename traits<MatrixType>::XprKind XprKind;
24 typedef typename ref_selector<MatrixType>::type MatrixTypeNested;
25 typedef std::remove_reference_t<MatrixTypeNested> MatrixTypeNested_;
27 RowsAtCompileTime = RowFactor ==
Dynamic || int(MatrixType::RowsAtCompileTime) ==
Dynamic
29 : RowFactor * MatrixType::RowsAtCompileTime,
30 ColsAtCompileTime = ColFactor ==
Dynamic || int(MatrixType::ColsAtCompileTime) ==
Dynamic
32 : ColFactor * MatrixType::ColsAtCompileTime,
34 MaxRowsAtCompileTime = RowsAtCompileTime,
35 MaxColsAtCompileTime = ColsAtCompileTime,
36 IsRowMajor = MaxRowsAtCompileTime == 1 && MaxColsAtCompileTime != 1 ? 1
37 : MaxColsAtCompileTime == 1 && MaxRowsAtCompileTime != 1 ? 0
63template <
typename MatrixType,
int RowFactor,
int ColFactor>
64class Replicate :
public internal::dense_xpr_base<Replicate<MatrixType, RowFactor, ColFactor> >::type {
65 typedef typename internal::traits<Replicate>::MatrixTypeNested MatrixTypeNested;
66 typedef typename internal::traits<Replicate>::MatrixTypeNested_ MatrixTypeNested_;
69 typedef typename internal::dense_xpr_base<Replicate>::type Base;
71 typedef internal::remove_all_t<MatrixType> NestedExpression;
73 template <
typename OriginalMatrixType>
74 EIGEN_DEVICE_FUNC
inline explicit Replicate(
const OriginalMatrixType& matrix)
75 : m_matrix(matrix), m_rowFactor(RowFactor), m_colFactor(ColFactor) {
76 EIGEN_STATIC_ASSERT((internal::is_same<std::remove_const_t<MatrixType>, OriginalMatrixType>::value),
77 THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE)
81 template <
typename OriginalMatrixType>
82 EIGEN_DEVICE_FUNC
inline Replicate(
const OriginalMatrixType& matrix,
Index rowFactor,
Index colFactor)
83 : m_matrix(matrix), m_rowFactor(rowFactor), m_colFactor(colFactor) {
84 EIGEN_STATIC_ASSERT((internal::is_same<std::remove_const_t<MatrixType>, OriginalMatrixType>::value),
85 THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE)
88 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index rows()
const {
return m_matrix.rows() * m_rowFactor.value(); }
89 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index cols()
const {
return m_matrix.cols() * m_colFactor.value(); }
91 EIGEN_DEVICE_FUNC
const MatrixTypeNested_& nestedExpression()
const {
return m_matrix; }
94 MatrixTypeNested m_matrix;
95 const internal::variable_if_dynamic<Index, RowFactor> m_rowFactor;
96 const internal::variable_if_dynamic<Index, ColFactor> m_colFactor;
107template <
typename Derived>
108template <
int RowFactor,
int ColFactor>
121template <
typename ExpressionType,
int Direction>
125 _expression(), Direction ==
Vertical ? factor : 1, Direction ==
Horizontal ? factor : 1);
const Replicate< Derived, RowFactor, ColFactor > replicate() const
Definition Replicate.h:109
Expression of the multiple replication of a matrix or vector.
Definition Replicate.h:64
Eigen::Index Index
Definition VectorwiseOp.h:196
const ReplicateReturnType replicate(Index factor) const
Definition Replicate.h:123
@ Horizontal
Definition Constants.h:269
@ Vertical
Definition Constants.h:266
const unsigned int RowMajorBit
Definition Constants.h:70
Namespace containing all symbols from the Eigen library.
Definition Core:137
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:83
const int Dynamic
Definition Constants.h:25