aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Eigenvalues/ComplexEigenSolver.h
diff options
context:
space:
mode:
authorGravatar Jitse Niesen <jitse@maths.leeds.ac.uk>2012-07-24 15:17:59 +0100
committerGravatar Jitse Niesen <jitse@maths.leeds.ac.uk>2012-07-24 15:17:59 +0100
commitba5eecae53aa038374d1708573cf03a2df3f76f3 (patch)
treeb1bb109190fc9b31cbbda8c227343170e2058307 /Eigen/src/Eigenvalues/ComplexEigenSolver.h
parentb7ac053b9c1196bf775ca0ec45765f6262648c43 (diff)
Allow user to specify max number of iterations (bug #479).
Diffstat (limited to 'Eigen/src/Eigenvalues/ComplexEigenSolver.h')
-rw-r--r--Eigen/src/Eigenvalues/ComplexEigenSolver.h36
1 files changed, 32 insertions, 4 deletions
diff --git a/Eigen/src/Eigenvalues/ComplexEigenSolver.h b/Eigen/src/Eigenvalues/ComplexEigenSolver.h
index c4b8a308c..39dfe2a0a 100644
--- a/Eigen/src/Eigenvalues/ComplexEigenSolver.h
+++ b/Eigen/src/Eigenvalues/ComplexEigenSolver.h
@@ -3,7 +3,7 @@
//
// Copyright (C) 2009 Claire Maurice
// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
-// Copyright (C) 2010 Jitse Niesen <jitse@maths.leeds.ac.uk>
+// Copyright (C) 2010,2012 Jitse Niesen <jitse@maths.leeds.ac.uk>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
@@ -208,7 +208,27 @@ template<typename _MatrixType> class ComplexEigenSolver
* Example: \include ComplexEigenSolver_compute.cpp
* Output: \verbinclude ComplexEigenSolver_compute.out
*/
- ComplexEigenSolver& compute(const MatrixType& matrix, bool computeEigenvectors = true);
+ ComplexEigenSolver& compute(const MatrixType& matrix, bool computeEigenvectors = true)
+ {
+ return computeInternal(matrix, computeEigenvectors, false, 0);
+ }
+
+ /** \brief Computes eigendecomposition with specified maximum number of iterations.
+ *
+ * \param[in] matrix Square matrix whose eigendecomposition is to be computed.
+ * \param[in] computeEigenvectors If true, both the eigenvectors and the
+ * eigenvalues are computed; if false, only the eigenvalues are
+ * computed.
+ * \param[in] maxIter Maximum number of iterations.
+ * \returns Reference to \c *this
+ *
+ * This method provides the same functionality as compute(const MatrixType&, bool) but it also allows the
+ * user to specify the maximum number of iterations to be used when computing the Schur decomposition.
+ */
+ ComplexEigenSolver& compute(const MatrixType& matrix, bool computeEigenvectors, Index maxIter)
+ {
+ return computeInternal(matrix, computeEigenvectors, true, maxIter);
+ }
/** \brief Reports whether previous computation was successful.
*
@@ -231,18 +251,26 @@ template<typename _MatrixType> class ComplexEigenSolver
private:
void doComputeEigenvectors(RealScalar matrixnorm);
void sortEigenvalues(bool computeEigenvectors);
+ ComplexEigenSolver& computeInternal(const MatrixType& matrix, bool computeEigenvectors,
+ bool maxIterSpecified, Index maxIter);
+
};
template<typename MatrixType>
-ComplexEigenSolver<MatrixType>& ComplexEigenSolver<MatrixType>::compute(const MatrixType& matrix, bool computeEigenvectors)
+ComplexEigenSolver<MatrixType>&
+ComplexEigenSolver<MatrixType>::computeInternal(const MatrixType& matrix, bool computeEigenvectors,
+ bool maxIterSpecified, Index maxIter)
{
// this code is inspired from Jampack
assert(matrix.cols() == matrix.rows());
// Do a complex Schur decomposition, A = U T U^*
// The eigenvalues are on the diagonal of T.
- m_schur.compute(matrix, computeEigenvectors);
+ if (maxIterSpecified)
+ m_schur.compute(matrix, computeEigenvectors, maxIter);
+ else
+ m_schur.compute(matrix, computeEigenvectors);
if(m_schur.info() == Success)
{