Warning, file /include/eigen3/Eigen/src/Core/Replicate.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 
0002 
0003 
0004 
0005 
0006 
0007 
0008 
0009 
0010 #ifndef EIGEN_REPLICATE_H
0011 #define EIGEN_REPLICATE_H
0012 
0013 namespace Eigen {
0014 
0015 namespace internal {
0016 template<typename MatrixType,int RowFactor,int ColFactor>
0017 struct traits<Replicate<MatrixType,RowFactor,ColFactor> >
0018  : traits<MatrixType>
0019 {
0020   typedef typename MatrixType::Scalar Scalar;
0021   typedef typename traits<MatrixType>::StorageKind StorageKind;
0022   typedef typename traits<MatrixType>::XprKind XprKind;
0023   typedef typename ref_selector<MatrixType>::type MatrixTypeNested;
0024   typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;
0025   enum {
0026     RowsAtCompileTime = RowFactor==Dynamic || int(MatrixType::RowsAtCompileTime)==Dynamic
0027                       ? Dynamic
0028                       : RowFactor * MatrixType::RowsAtCompileTime,
0029     ColsAtCompileTime = ColFactor==Dynamic || int(MatrixType::ColsAtCompileTime)==Dynamic
0030                       ? Dynamic
0031                       : ColFactor * MatrixType::ColsAtCompileTime,
0032    
0033     MaxRowsAtCompileTime = RowsAtCompileTime,
0034     MaxColsAtCompileTime = ColsAtCompileTime,
0035     IsRowMajor = MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1 ? 1
0036                : MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1 ? 0
0037                : (MatrixType::Flags & RowMajorBit) ? 1 : 0,
0038 
0039     
0040     Flags = IsRowMajor ? RowMajorBit : 0
0041   };
0042 };
0043 }
0044 
0045 
0046 
0047 
0048 
0049 
0050 
0051 
0052 
0053 
0054 
0055 
0056 
0057 
0058 
0059 
0060 
0061 template<typename MatrixType,int RowFactor,int ColFactor> class Replicate
0062   : public internal::dense_xpr_base< Replicate<MatrixType,RowFactor,ColFactor> >::type
0063 {
0064     typedef typename internal::traits<Replicate>::MatrixTypeNested MatrixTypeNested;
0065     typedef typename internal::traits<Replicate>::_MatrixTypeNested _MatrixTypeNested;
0066   public:
0067 
0068     typedef typename internal::dense_xpr_base<Replicate>::type Base;
0069     EIGEN_DENSE_PUBLIC_INTERFACE(Replicate)
0070     typedef typename internal::remove_all<MatrixType>::type NestedExpression;
0071 
0072     template<typename OriginalMatrixType>
0073     EIGEN_DEVICE_FUNC
0074     inline explicit Replicate(const OriginalMatrixType& matrix)
0075       : m_matrix(matrix), m_rowFactor(RowFactor), m_colFactor(ColFactor)
0076     {
0077       EIGEN_STATIC_ASSERT((internal::is_same<typename internal::remove_const<MatrixType>::type,OriginalMatrixType>::value),
0078                           THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE)
0079       eigen_assert(RowFactor!=Dynamic && ColFactor!=Dynamic);
0080     }
0081 
0082     template<typename OriginalMatrixType>
0083     EIGEN_DEVICE_FUNC
0084     inline Replicate(const OriginalMatrixType& matrix, Index rowFactor, Index colFactor)
0085       : m_matrix(matrix), m_rowFactor(rowFactor), m_colFactor(colFactor)
0086     {
0087       EIGEN_STATIC_ASSERT((internal::is_same<typename internal::remove_const<MatrixType>::type,OriginalMatrixType>::value),
0088                           THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE)
0089     }
0090 
0091     EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
0092     inline Index rows() const { return m_matrix.rows() * m_rowFactor.value(); }
0093     EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
0094     inline Index cols() const { return m_matrix.cols() * m_colFactor.value(); }
0095 
0096     EIGEN_DEVICE_FUNC
0097     const _MatrixTypeNested& nestedExpression() const
0098     {
0099       return m_matrix;
0100     }
0101 
0102   protected:
0103     MatrixTypeNested m_matrix;
0104     const internal::variable_if_dynamic<Index, RowFactor> m_rowFactor;
0105     const internal::variable_if_dynamic<Index, ColFactor> m_colFactor;
0106 };
0107 
0108 
0109 
0110 
0111 
0112 
0113 
0114 
0115 
0116 template<typename Derived>
0117 template<int RowFactor, int ColFactor>
0118 EIGEN_DEVICE_FUNC const Replicate<Derived,RowFactor,ColFactor>
0119 DenseBase<Derived>::replicate() const
0120 {
0121   return Replicate<Derived,RowFactor,ColFactor>(derived());
0122 }
0123 
0124 
0125 
0126 
0127 
0128 
0129 
0130 
0131 
0132 template<typename ExpressionType, int Direction>
0133 EIGEN_DEVICE_FUNC const typename VectorwiseOp<ExpressionType,Direction>::ReplicateReturnType
0134 VectorwiseOp<ExpressionType,Direction>::replicate(Index factor) const
0135 {
0136   return typename VectorwiseOp<ExpressionType,Direction>::ReplicateReturnType
0137           (_expression(),Direction==Vertical?factor:1,Direction==Horizontal?factor:1);
0138 }
0139 
0140 } 
0141 
0142 #endif