Medial Code Documentation
Loading...
Searching...
No Matches
Replicate.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
5//
6// This Source Code Form is subject to the terms of the Mozilla
7// Public License v. 2.0. If a copy of the MPL was not distributed
8// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
10#ifndef EIGEN_REPLICATE_H
11#define EIGEN_REPLICATE_H
12
13namespace Eigen {
14
30namespace internal {
31template<typename MatrixType,int RowFactor,int ColFactor>
32struct traits<Replicate<MatrixType,RowFactor,ColFactor> >
33 : traits<MatrixType>
34{
35 typedef typename MatrixType::Scalar Scalar;
37 typedef typename traits<MatrixType>::XprKind XprKind;
39 typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;
40 enum {
41 RowsAtCompileTime = RowFactor==Dynamic || int(MatrixType::RowsAtCompileTime)==Dynamic
42 ? Dynamic
43 : RowFactor * MatrixType::RowsAtCompileTime,
44 ColsAtCompileTime = ColFactor==Dynamic || int(MatrixType::ColsAtCompileTime)==Dynamic
45 ? Dynamic
46 : ColFactor * MatrixType::ColsAtCompileTime,
47 //FIXME we don't propagate the max sizes !!!
48 MaxRowsAtCompileTime = RowsAtCompileTime,
49 MaxColsAtCompileTime = ColsAtCompileTime,
50 IsRowMajor = MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1 ? 1
51 : MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1 ? 0
52 : (MatrixType::Flags & RowMajorBit) ? 1 : 0,
53
54 // FIXME enable DirectAccess with negative strides?
55 Flags = IsRowMajor ? RowMajorBit : 0
56 };
57};
58}
59
60template<typename MatrixType,int RowFactor,int ColFactor> class Replicate
61 : public internal::dense_xpr_base< Replicate<MatrixType,RowFactor,ColFactor> >::type
62{
63 typedef typename internal::traits<Replicate>::MatrixTypeNested MatrixTypeNested;
64 typedef typename internal::traits<Replicate>::_MatrixTypeNested _MatrixTypeNested;
65 public:
66
68 EIGEN_DENSE_PUBLIC_INTERFACE(Replicate)
70
71 template<typename OriginalMatrixType>
73 inline explicit Replicate(const OriginalMatrixType& matrix)
74 : m_matrix(matrix), m_rowFactor(RowFactor), m_colFactor(ColFactor)
75 {
76 EIGEN_STATIC_ASSERT((internal::is_same<typename internal::remove_const<MatrixType>::type,OriginalMatrixType>::value),
77 THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE)
78 eigen_assert(RowFactor!=Dynamic && ColFactor!=Dynamic);
79 }
80
81 template<typename OriginalMatrixType>
83 inline Replicate(const OriginalMatrixType& matrix, Index rowFactor, Index colFactor)
84 : m_matrix(matrix), m_rowFactor(rowFactor), m_colFactor(colFactor)
85 {
86 EIGEN_STATIC_ASSERT((internal::is_same<typename internal::remove_const<MatrixType>::type,OriginalMatrixType>::value),
87 THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE)
88 }
89
91 inline Index rows() const { return m_matrix.rows() * m_rowFactor.value(); }
93 inline Index cols() const { return m_matrix.cols() * m_colFactor.value(); }
94
96 const _MatrixTypeNested& nestedExpression() const
97 {
98 return m_matrix;
99 }
100
101 protected:
102 MatrixTypeNested m_matrix;
105};
106
115template<typename Derived>
116template<int RowFactor, int ColFactor>
122
131template<typename ExpressionType, int Direction>
134{
136 (_expression(),Direction==Vertical?factor:1,Direction==Horizontal?factor:1);
137}
138
139} // end namespace Eigen
140
141#endif // EIGEN_REPLICATE_H
Base class for all dense matrices, vectors, and arrays.
Definition DenseBase.h:49
Expression of the multiple replication of a matrix or vector.
Definition Replicate.h:62
Pseudo expression representing a solving operation.
Definition Solve.h:63
Pseudo expression providing partial reduction operations.
Definition VectorwiseOp.h:157
Eigen::Index Index
Definition VectorwiseOp.h:162
Definition XprHelper.h:67
@ Horizontal
For Reverse, all rows are reversed; for PartialReduxExpr and VectorwiseOp, act on rows.
Definition Constants.h:268
@ Vertical
For Reverse, all columns are reversed; for PartialReduxExpr and VectorwiseOp, act on columns.
Definition Constants.h:265
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition Constants.h:61
Definition XprHelper.h:428
Definition Meta.h:39
Definition ForwardDeclarations.h:17
Definition Meta.h:30