25 #ifndef EIGEN_TRANSPOSITIONS_H
26 #define EIGEN_TRANSPOSITIONS_H
60 template<
typename TranspositionType,
typename MatrixType,
int S
ide,
bool Transposed=false>
struct transposition_matrix_product_retval;
63 template<
typename Derived>
66 typedef internal::traits<Derived> Traits;
73 Derived&
derived() {
return *
static_cast<Derived*
>(
this); }
74 const Derived&
derived()
const {
return *
static_cast<const Derived*
>(
this); }
77 template<
typename OtherDerived>
84 #ifndef EIGEN_PARSED_BY_DOXYGEN
125 for(
int i = 0; i <
indices().size(); ++i)
162 template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename IndexType>
163 struct traits<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,IndexType> >
165 typedef IndexType Index;
166 typedef Matrix<Index, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType;
170 template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename IndexType>
173 typedef internal::traits<Transpositions> Traits;
183 template<
typename OtherDerived>
187 #ifndef EIGEN_PARSED_BY_DOXYGEN
194 template<
typename Other>
199 template<
typename OtherDerived>
205 #ifndef EIGEN_PARSED_BY_DOXYGEN
233 template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename IndexType,
int _PacketAccess>
234 struct traits<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,IndexType>,_PacketAccess> >
236 typedef IndexType Index;
241 template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename IndexType,
int PacketAccess>
243 :
public TranspositionsBase<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,IndexType>,PacketAccess> >
245 typedef internal::traits<Map> Traits;
250 typedef typename IndicesType::Scalar
Index;
257 : m_indices(indices,size)
261 template<
typename OtherDerived>
264 return Base::operator=(other);
267 #ifndef EIGEN_PARSED_BY_DOXYGEN
271 Map& operator=(
const Map& other)
273 m_indices = other.m_indices;
290 template<
typename _IndicesType>
291 struct traits<TranspositionsWrapper<_IndicesType> >
293 typedef typename _IndicesType::Scalar Index;
294 typedef _IndicesType IndicesType;
298 template<
typename _IndicesType>
302 typedef internal::traits<TranspositionsWrapper> Traits;
307 typedef typename IndicesType::Scalar
Index;
314 template<
typename OtherDerived>
320 #ifndef EIGEN_PARSED_BY_DOXYGEN
344 template<
typename Derived,
typename TranspositionsDerived>
345 inline const internal::transposition_matrix_product_retval<TranspositionsDerived, Derived, OnTheRight>
349 return internal::transposition_matrix_product_retval
351 (transpositions.
derived(), matrix.derived());
356 template<
typename Derived,
typename TranspositionDerived>
357 inline const internal::transposition_matrix_product_retval
358 <TranspositionDerived, Derived,
OnTheLeft>
362 return internal::transposition_matrix_product_retval
363 <TranspositionDerived, Derived,
OnTheLeft>
364 (transpositions.
derived(), matrix.derived());
369 template<
typename TranspositionType,
typename MatrixType,
int S
ide,
bool Transposed>
370 struct traits<transposition_matrix_product_retval<TranspositionType, MatrixType, Side, Transposed> >
372 typedef typename MatrixType::PlainObject ReturnType;
375 template<
typename TranspositionType,
typename MatrixType,
int S
ide,
bool Transposed>
376 struct transposition_matrix_product_retval
377 :
public ReturnByValue<transposition_matrix_product_retval<TranspositionType, MatrixType, Side, Transposed> >
379 typedef typename remove_all<typename MatrixType::Nested>::type MatrixTypeNestedCleaned;
380 typedef typename TranspositionType::Index Index;
382 transposition_matrix_product_retval(
const TranspositionType& tr,
const MatrixType& matrix)
383 : m_transpositions(tr), m_matrix(matrix)
386 inline int rows()
const {
return m_matrix.rows(); }
387 inline int cols()
const {
return m_matrix.cols(); }
389 template<
typename Dest>
inline void evalTo(Dest& dst)
const
391 const int size = m_transpositions.size();
397 for(
int k=(Transposed?size-1:0) ; Transposed?k>=0:k<size ; Transposed?--k:++k)
398 if((j=m_transpositions.coeff(k))!=k)
401 dst.row(k).swap(dst.row(j));
403 dst.col(k).swap(dst.col(j));
408 const TranspositionType& m_transpositions;
409 typename MatrixType::Nested m_matrix;
416 template<
typename TranspositionsDerived>
419 typedef TranspositionsDerived TranspositionType;
420 typedef typename TranspositionType::IndicesType IndicesType;
423 Transpose(
const TranspositionType& t) : m_transpositions(t) {}
425 inline int size()
const {
return m_transpositions.size(); }
429 template<
typename Derived>
friend
430 inline const internal::transposition_matrix_product_retval<TranspositionType, Derived, OnTheRight, true>
433 return internal::transposition_matrix_product_retval<TranspositionType, Derived, OnTheRight, true>(trt.m_transpositions, matrix.derived());
438 template<
typename Derived>
439 inline const internal::transposition_matrix_product_retval<TranspositionType, Derived, OnTheLeft, true>
442 return internal::transposition_matrix_product_retval<TranspositionType, Derived, OnTheLeft, true>(m_transpositions, matrix.derived());
451 #endif // EIGEN_TRANSPOSITIONS_H