mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Make constructors explicit if they could lead to unintended implicit conversion
This commit is contained in:
@@ -104,7 +104,7 @@ template<typename _MatrixType> class ComplexEigenSolver
|
||||
* according to the specified problem \a size.
|
||||
* \sa ComplexEigenSolver()
|
||||
*/
|
||||
ComplexEigenSolver(Index size)
|
||||
explicit ComplexEigenSolver(Index size)
|
||||
: m_eivec(size, size),
|
||||
m_eivalues(size),
|
||||
m_schur(size),
|
||||
@@ -122,7 +122,7 @@ template<typename _MatrixType> class ComplexEigenSolver
|
||||
*
|
||||
* This constructor calls compute() to compute the eigendecomposition.
|
||||
*/
|
||||
ComplexEigenSolver(const MatrixType& matrix, bool computeEigenvectors = true)
|
||||
explicit ComplexEigenSolver(const MatrixType& matrix, bool computeEigenvectors = true)
|
||||
: m_eivec(matrix.rows(),matrix.cols()),
|
||||
m_eivalues(matrix.cols()),
|
||||
m_schur(matrix.rows()),
|
||||
|
||||
@@ -91,7 +91,7 @@ template<typename _MatrixType> class ComplexSchur
|
||||
*
|
||||
* \sa compute() for an example.
|
||||
*/
|
||||
ComplexSchur(Index size = RowsAtCompileTime==Dynamic ? 1 : RowsAtCompileTime)
|
||||
explicit ComplexSchur(Index size = RowsAtCompileTime==Dynamic ? 1 : RowsAtCompileTime)
|
||||
: m_matT(size,size),
|
||||
m_matU(size,size),
|
||||
m_hess(size),
|
||||
@@ -109,7 +109,7 @@ template<typename _MatrixType> class ComplexSchur
|
||||
*
|
||||
* \sa matrixT() and matrixU() for examples.
|
||||
*/
|
||||
ComplexSchur(const MatrixType& matrix, bool computeU = true)
|
||||
explicit ComplexSchur(const MatrixType& matrix, bool computeU = true)
|
||||
: m_matT(matrix.rows(),matrix.cols()),
|
||||
m_matU(matrix.rows(),matrix.cols()),
|
||||
m_hess(matrix.rows()),
|
||||
|
||||
@@ -118,7 +118,7 @@ template<typename _MatrixType> class EigenSolver
|
||||
* according to the specified problem \a size.
|
||||
* \sa EigenSolver()
|
||||
*/
|
||||
EigenSolver(Index size)
|
||||
explicit EigenSolver(Index size)
|
||||
: m_eivec(size, size),
|
||||
m_eivalues(size),
|
||||
m_isInitialized(false),
|
||||
@@ -143,7 +143,7 @@ template<typename _MatrixType> class EigenSolver
|
||||
*
|
||||
* \sa compute()
|
||||
*/
|
||||
EigenSolver(const MatrixType& matrix, bool computeEigenvectors = true)
|
||||
explicit EigenSolver(const MatrixType& matrix, bool computeEigenvectors = true)
|
||||
: m_eivec(matrix.rows(), matrix.cols()),
|
||||
m_eivalues(matrix.cols()),
|
||||
m_isInitialized(false),
|
||||
|
||||
@@ -122,7 +122,7 @@ template<typename _MatrixType> class GeneralizedEigenSolver
|
||||
* according to the specified problem \a size.
|
||||
* \sa GeneralizedEigenSolver()
|
||||
*/
|
||||
GeneralizedEigenSolver(Index size)
|
||||
explicit GeneralizedEigenSolver(Index size)
|
||||
: m_eivec(size, size),
|
||||
m_alphas(size),
|
||||
m_betas(size),
|
||||
@@ -145,7 +145,7 @@ template<typename _MatrixType> class GeneralizedEigenSolver
|
||||
*
|
||||
* \sa compute()
|
||||
*/
|
||||
GeneralizedEigenSolver(const MatrixType& A, const MatrixType& B, bool computeEigenvectors = true)
|
||||
explicit GeneralizedEigenSolver(const MatrixType& A, const MatrixType& B, bool computeEigenvectors = true)
|
||||
: m_eivec(A.rows(), A.cols()),
|
||||
m_alphas(A.cols()),
|
||||
m_betas(A.cols()),
|
||||
|
||||
@@ -74,7 +74,7 @@ class GeneralizedSelfAdjointEigenSolver : public SelfAdjointEigenSolver<_MatrixT
|
||||
*
|
||||
* \sa compute() for an example
|
||||
*/
|
||||
GeneralizedSelfAdjointEigenSolver(Index size)
|
||||
explicit GeneralizedSelfAdjointEigenSolver(Index size)
|
||||
: Base(size)
|
||||
{}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ template<typename _MatrixType> class HessenbergDecomposition
|
||||
*
|
||||
* \sa compute() for an example.
|
||||
*/
|
||||
HessenbergDecomposition(Index size = Size==Dynamic ? 2 : Size)
|
||||
explicit HessenbergDecomposition(Index size = Size==Dynamic ? 2 : Size)
|
||||
: m_matrix(size,size),
|
||||
m_temp(size),
|
||||
m_isInitialized(false)
|
||||
@@ -115,7 +115,7 @@ template<typename _MatrixType> class HessenbergDecomposition
|
||||
*
|
||||
* \sa matrixH() for an example.
|
||||
*/
|
||||
HessenbergDecomposition(const MatrixType& matrix)
|
||||
explicit HessenbergDecomposition(const MatrixType& matrix)
|
||||
: m_matrix(matrix),
|
||||
m_temp(matrix.rows()),
|
||||
m_isInitialized(false)
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace Eigen {
|
||||
*
|
||||
* \sa compute() for an example.
|
||||
*/
|
||||
RealQZ(Index size = RowsAtCompileTime==Dynamic ? 1 : RowsAtCompileTime) :
|
||||
explicit RealQZ(Index size = RowsAtCompileTime==Dynamic ? 1 : RowsAtCompileTime) :
|
||||
m_S(size, size),
|
||||
m_T(size, size),
|
||||
m_Q(size, size),
|
||||
@@ -101,7 +101,7 @@ namespace Eigen {
|
||||
*
|
||||
* This constructor calls compute() to compute the QZ decomposition.
|
||||
*/
|
||||
RealQZ(const MatrixType& A, const MatrixType& B, bool computeQZ = true) :
|
||||
explicit RealQZ(const MatrixType& A, const MatrixType& B, bool computeQZ = true) :
|
||||
m_S(A.rows(),A.cols()),
|
||||
m_T(A.rows(),A.cols()),
|
||||
m_Q(A.rows(),A.cols()),
|
||||
|
||||
@@ -80,7 +80,7 @@ template<typename _MatrixType> class RealSchur
|
||||
*
|
||||
* \sa compute() for an example.
|
||||
*/
|
||||
RealSchur(Index size = RowsAtCompileTime==Dynamic ? 1 : RowsAtCompileTime)
|
||||
explicit RealSchur(Index size = RowsAtCompileTime==Dynamic ? 1 : RowsAtCompileTime)
|
||||
: m_matT(size, size),
|
||||
m_matU(size, size),
|
||||
m_workspaceVector(size),
|
||||
@@ -100,7 +100,7 @@ template<typename _MatrixType> class RealSchur
|
||||
* Example: \include RealSchur_RealSchur_MatrixType.cpp
|
||||
* Output: \verbinclude RealSchur_RealSchur_MatrixType.out
|
||||
*/
|
||||
RealSchur(const MatrixType& matrix, bool computeU = true)
|
||||
explicit RealSchur(const MatrixType& matrix, bool computeU = true)
|
||||
: m_matT(matrix.rows(),matrix.cols()),
|
||||
m_matU(matrix.rows(),matrix.cols()),
|
||||
m_workspaceVector(matrix.rows()),
|
||||
|
||||
@@ -133,7 +133,7 @@ template<typename _MatrixType> class SelfAdjointEigenSolver
|
||||
* \sa compute() for an example
|
||||
*/
|
||||
EIGEN_DEVICE_FUNC
|
||||
SelfAdjointEigenSolver(Index size)
|
||||
explicit SelfAdjointEigenSolver(Index size)
|
||||
: m_eivec(size, size),
|
||||
m_eivalues(size),
|
||||
m_subdiag(size > 1 ? size - 1 : 1),
|
||||
@@ -156,7 +156,7 @@ template<typename _MatrixType> class SelfAdjointEigenSolver
|
||||
* \sa compute(const MatrixType&, int)
|
||||
*/
|
||||
EIGEN_DEVICE_FUNC
|
||||
SelfAdjointEigenSolver(const MatrixType& matrix, int options = ComputeEigenvectors)
|
||||
explicit SelfAdjointEigenSolver(const MatrixType& matrix, int options = ComputeEigenvectors)
|
||||
: m_eivec(matrix.rows(), matrix.cols()),
|
||||
m_eivalues(matrix.cols()),
|
||||
m_subdiag(matrix.rows() > 1 ? matrix.rows() - 1 : 1),
|
||||
|
||||
@@ -112,7 +112,7 @@ template<typename _MatrixType> class Tridiagonalization
|
||||
*
|
||||
* \sa compute() for an example.
|
||||
*/
|
||||
Tridiagonalization(Index size = Size==Dynamic ? 2 : Size)
|
||||
explicit Tridiagonalization(Index size = Size==Dynamic ? 2 : Size)
|
||||
: m_matrix(size,size),
|
||||
m_hCoeffs(size > 1 ? size-1 : 1),
|
||||
m_isInitialized(false)
|
||||
@@ -128,7 +128,7 @@ template<typename _MatrixType> class Tridiagonalization
|
||||
* Example: \include Tridiagonalization_Tridiagonalization_MatrixType.cpp
|
||||
* Output: \verbinclude Tridiagonalization_Tridiagonalization_MatrixType.out
|
||||
*/
|
||||
Tridiagonalization(const MatrixType& matrix)
|
||||
explicit Tridiagonalization(const MatrixType& matrix)
|
||||
: m_matrix(matrix),
|
||||
m_hCoeffs(matrix.cols() > 1 ? matrix.cols()-1 : 1),
|
||||
m_isInitialized(false)
|
||||
|
||||
Reference in New Issue
Block a user