26 template<
typename MatrixType,
int Dim>
27 struct traits<VecAsSymmMatrix<MatrixType,Dim> >
30 typedef typename MatrixType::Scalar Scalar;
31 typedef typename traits<MatrixType>::StorageKind StorageKind;
32 typedef typename traits<MatrixType>::XprKind XprKind;
33 typedef typename ref_selector<MatrixType>::type MatrixTypeNested;
34 typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;
36 RowsAtCompileTime = Dim==Dynamic || int(MatrixType::RowsAtCompileTime)==Dynamic
38 : Dim * MatrixType::RowsAtCompileTime,
39 ColsAtCompileTime = Dim==Dynamic || int(MatrixType::ColsAtCompileTime)==Dynamic
41 : Dim * MatrixType::ColsAtCompileTime,
43 MaxRowsAtCompileTime = RowsAtCompileTime,
44 MaxColsAtCompileTime = ColsAtCompileTime,
45 IsRowMajor = MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1 ? 1
46 : MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1 ? 0
47 : (MatrixType::Flags & RowMajorBit) ? 1 : 0,
50 Flags = IsRowMajor ? RowMajorBit : 0
56 :
public internal::dense_xpr_base< VecAsSymmMatrix<MatrixType,Dim> >::type
58 typedef typename internal::traits<VecAsSymmMatrix>::MatrixTypeNested MatrixTypeNested;
59 typedef typename internal::traits<VecAsSymmMatrix>::_MatrixTypeNested _MatrixTypeNested;
62 typedef typename internal::dense_xpr_base<VecAsSymmMatrix>::type Base;
64 typedef typename internal::remove_all<MatrixType>::type NestedExpression;
66 template<
typename OriginalMatrixType>
69 : m_matrix(a_matrix), m_mdim(Dim)
71 EIGEN_STATIC_ASSERT((internal::is_same<
typename internal::remove_const<MatrixType>::type,OriginalMatrixType>::value),
72 THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE)
73 eigen_assert(Dim!=Dynamic);
76 template<
typename OriginalMatrixType>
78 inline VecAsSymmMatrix(
const OriginalMatrixType& a_matrix, Index mdim)
79 : m_matrix(a_matrix), m_mdim(mdim)
81 EIGEN_STATIC_ASSERT((internal::is_same<
typename internal::remove_const<MatrixType>::type,OriginalMatrixType>::value),
82 THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE)
86 inline Index rows()
const {
return m_mdim.value(); }
89 inline Index cols()
const {
return m_mdim.value(); }
123 const _MatrixTypeNested& nestedExpression()
const
129 MatrixTypeNested m_matrix;
130 const internal::variable_if_dynamic<Index, Dim> m_mdim;
134 template<
typename ArgType,
int Dim>
136 : evaluator_base<VecAsSymmMatrix<ArgType, Dim> >
139 typedef typename XprType::CoeffReturnType CoeffReturnType;
141 Factor = (Dim==Dynamic) ? Dynamic : Dim*Dim
143 typedef typename internal::nested_eval<ArgType,Factor>::type ArgTypeNested;
144 typedef typename internal::remove_all<ArgTypeNested>::type ArgTypeNestedCleaned;
147 CoeffReadCost = evaluator<ArgTypeNestedCleaned>::CoeffReadCost,
148 LinearAccessMask = XprType::IsVectorAtCompileTime ? LinearAccessBit : 0,
149 Flags = (evaluator<ArgTypeNestedCleaned>::Flags & (HereditaryBits|LinearAccessMask) & ~RowMajorBit) | (traits<XprType>::Flags & RowMajorBit),
151 Alignment = evaluator<ArgTypeNestedCleaned>::Alignment
154 EIGEN_DEVICE_FUNC
explicit unary_evaluator(
const XprType& xpr)
155 : m_arg(xpr.nestedExpression()),
157 m_rows(xpr.nestedExpression().rows()),
158 m_cols(xpr.nestedExpression().cols())
161 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
162 CoeffReturnType coeff(Index rowId, Index colId)
const
164 if ( rowId / m_rows.value() != colId / m_cols.value() )
165 return CoeffReturnType(0);
167 const Index actual_row = internal::traits<XprType>::RowsAtCompileTime==1 ? 0
169 : rowId%m_rows.value();
170 const Index actual_col = internal::traits<XprType>::ColsAtCompileTime==1 ? 0
172 : colId%m_cols.value();
174 return m_argImpl.coeff(actual_row, actual_col);
177 template<
int LoadMode,
typename PacketType>
179 PacketType packet(Index rowId, Index colId)
const
181 assert( rowId / m_rows.value() != colId / m_cols.value() &&
184 const Index actual_row = internal::traits<XprType>::RowsAtCompileTime==1 ? 0
186 : rowId%m_rows.value();
187 const Index actual_col = internal::traits<XprType>::ColsAtCompileTime==1 ? 0
189 : colId%m_cols.value();
191 return m_argImpl.template packet<LoadMode>(actual_row, actual_col);
196 evaluator<ArgTypeNestedCleaned> m_argImpl;
197 const variable_if_dynamic<Index, ArgType::RowsAtCompileTime> m_rows;
198 const variable_if_dynamic<Index, ArgType::ColsAtCompileTime> m_cols;
211 template<
typename Derived>
212 const typename MatrixBase<Derived>::VecAsSymmMatrixReturnType
213 MatrixBase<Derived>::blockDiag(Index mdim)
const
215 return VecAsSymmMatrix<Derived,Dynamic>(derived(),mdim);
Expression for presenting a vector as a DimxDim symmetric matrix.
Definition: VecAsSymmMatrix.h:55