diff options
author | 2010-06-08 22:23:11 +0200 | |
---|---|---|
committer | 2010-06-08 22:23:11 +0200 | |
commit | 50e43bc75ad3cccc5e9755bac16c5023dd22eba4 (patch) | |
tree | 1ba9e1840b56464515db42092bc6c4f783cc131a /Eigen/src/Core/PermutationMatrix.h | |
parent | 684656d41c3b1b87018719a474ec8c7c244fffa2 (diff) |
* add Transpositions to PermutationMatrix conversion
* make PartialPivLu uses the Transpositions class
Diffstat (limited to 'Eigen/src/Core/PermutationMatrix.h')
-rw-r--r-- | Eigen/src/Core/PermutationMatrix.h | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/Eigen/src/Core/PermutationMatrix.h b/Eigen/src/Core/PermutationMatrix.h index d3e36c73a..6ce357091 100644 --- a/Eigen/src/Core/PermutationMatrix.h +++ b/Eigen/src/Core/PermutationMatrix.h @@ -47,7 +47,6 @@ * * \sa class DiagonalMatrix */ -template<int SizeAtCompileTime, int MaxSizeAtCompileTime = SizeAtCompileTime> class PermutationMatrix; template<typename PermutationType, typename MatrixType, int Side, bool Transposed=false> struct ei_permut_matrix_product_retval; template<int SizeAtCompileTime, int MaxSizeAtCompileTime> @@ -78,8 +77,12 @@ class PermutationMatrix : public EigenBase<PermutationMatrix<SizeAtCompileTime, typedef Matrix<int, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType; inline PermutationMatrix() - { - } + {} + + /** Constructs an uninitialized permutation matrix of given size. + */ + inline PermutationMatrix(int size) : m_indices(size) + {} /** Copy constructor. */ template<int OtherSize, int OtherMaxSize> @@ -103,6 +106,14 @@ class PermutationMatrix : public EigenBase<PermutationMatrix<SizeAtCompileTime, explicit inline PermutationMatrix(const MatrixBase<Other>& indices) : m_indices(indices) {} + /** Convert the Transpositions \a tr to a permutation matrix */ + template<int OtherSize, int OtherMaxSize> + explicit PermutationMatrix(const Transpositions<OtherSize,OtherMaxSize>& tr) + : m_indices(tr.size()) + { + *this = tr; + } + /** Copies the other permutation into *this */ template<int OtherSize, int OtherMaxSize> PermutationMatrix& operator=(const PermutationMatrix<OtherSize, OtherMaxSize>& other) @@ -111,6 +122,15 @@ class PermutationMatrix : public EigenBase<PermutationMatrix<SizeAtCompileTime, return *this; } + /** Assignment from the Transpositions \a tr */ + template<int OtherSize, int OtherMaxSize> + PermutationMatrix& operator=(const Transpositions<OtherSize,OtherMaxSize>& tr) + { + setIdentity(tr.size()); + for(int k=size()-1; k>=0; --k) + applyTranspositionOnTheRight(k,tr.coeff(k)); + } + #ifndef EIGEN_PARSED_BY_DOXYGEN /** This is a special case of the templated operator=. Its purpose is to * prevent a default operator= from hiding the templated operator=. @@ -122,11 +142,6 @@ class PermutationMatrix : public EigenBase<PermutationMatrix<SizeAtCompileTime, } #endif - /** Constructs an uninitialized permutation matrix of given size. - */ - inline PermutationMatrix(int size) : m_indices(size) - {} - /** \returns the number of rows */ inline int rows() const { return m_indices.size(); } |