fix compile errors in Tridiagonalization and in doc examples

This commit is contained in:
Benoit Jacob 2010-12-30 04:52:20 -05:00
parent dbd9c5fd50
commit 26c2afd55a
4 changed files with 16 additions and 16 deletions

View File

@ -97,15 +97,15 @@ template<typename _MatrixType> class Tridiagonalization
typedef internal::TridiagonalizationMatrixTReturnType<MatrixTypeRealView> MatrixTReturnType; typedef internal::TridiagonalizationMatrixTReturnType<MatrixTypeRealView> MatrixTReturnType;
typedef typename internal::conditional<NumTraits<Scalar>::IsComplex, typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
typename Diagonal<MatrixType,0>::RealReturnType, const typename Diagonal<const MatrixType>::RealReturnType,
Diagonal<MatrixType,0> const Diagonal<const MatrixType>
>::type DiagonalReturnType; >::type DiagonalReturnType;
typedef typename internal::conditional<NumTraits<Scalar>::IsComplex, typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
typename Diagonal< const typename Diagonal<
Block<MatrixType,SizeMinusOne,SizeMinusOne>,0 >::RealReturnType, Block<const MatrixType,SizeMinusOne,SizeMinusOne> >::RealReturnType,
Diagonal< const Diagonal<
Block<MatrixType,SizeMinusOne,SizeMinusOne>,0 > Block<const MatrixType,SizeMinusOne,SizeMinusOne> >
>::type SubDiagonalReturnType; >::type SubDiagonalReturnType;
/** \brief Return type of matrixQ() */ /** \brief Return type of matrixQ() */
@ -292,7 +292,7 @@ template<typename _MatrixType> class Tridiagonalization
* *
* \sa matrixT(), subDiagonal() * \sa matrixT(), subDiagonal()
*/ */
const DiagonalReturnType diagonal() const; DiagonalReturnType diagonal() const;
/** \brief Returns the subdiagonal of the tridiagonal matrix T in the decomposition. /** \brief Returns the subdiagonal of the tridiagonal matrix T in the decomposition.
* *
@ -304,7 +304,7 @@ template<typename _MatrixType> class Tridiagonalization
* *
* \sa diagonal() for an example, matrixT() * \sa diagonal() for an example, matrixT()
*/ */
const SubDiagonalReturnType subDiagonal() const; SubDiagonalReturnType subDiagonal() const;
protected: protected:
@ -314,7 +314,7 @@ template<typename _MatrixType> class Tridiagonalization
}; };
template<typename MatrixType> template<typename MatrixType>
const typename Tridiagonalization<MatrixType>::DiagonalReturnType typename Tridiagonalization<MatrixType>::DiagonalReturnType
Tridiagonalization<MatrixType>::diagonal() const Tridiagonalization<MatrixType>::diagonal() const
{ {
eigen_assert(m_isInitialized && "Tridiagonalization is not initialized."); eigen_assert(m_isInitialized && "Tridiagonalization is not initialized.");
@ -322,12 +322,12 @@ Tridiagonalization<MatrixType>::diagonal() const
} }
template<typename MatrixType> template<typename MatrixType>
const typename Tridiagonalization<MatrixType>::SubDiagonalReturnType typename Tridiagonalization<MatrixType>::SubDiagonalReturnType
Tridiagonalization<MatrixType>::subDiagonal() const Tridiagonalization<MatrixType>::subDiagonal() const
{ {
eigen_assert(m_isInitialized && "Tridiagonalization is not initialized."); eigen_assert(m_isInitialized && "Tridiagonalization is not initialized.");
Index n = m_matrix.rows(); Index n = m_matrix.rows();
return Block<MatrixType,SizeMinusOne,SizeMinusOne>(m_matrix, 1, 0, n-1,n-1).diagonal(); return Block<const MatrixType,SizeMinusOne,SizeMinusOne>(m_matrix, 1, 0, n-1,n-1).diagonal();
} }
namespace internal { namespace internal {

View File

@ -11,10 +11,10 @@ firstTwo(MatrixBase<Derived>& v)
} }
template<typename Derived> template<typename Derived>
const Eigen::VectorBlock<Derived, 2> const Eigen::VectorBlock<const Derived, 2>
firstTwo(const MatrixBase<Derived>& v) firstTwo(const MatrixBase<Derived>& v)
{ {
return Eigen::VectorBlock<Derived, 2>(v.derived(), 0); return Eigen::VectorBlock<const Derived, 2>(v.derived(), 0);
} }
int main(int, char**) int main(int, char**)

View File

@ -11,10 +11,10 @@ segmentFromRange(MatrixBase<Derived>& v, int start, int end)
} }
template<typename Derived> template<typename Derived>
const Eigen::VectorBlock<Derived> const Eigen::VectorBlock<const Derived>
segmentFromRange(const MatrixBase<Derived>& v, int start, int end) segmentFromRange(const MatrixBase<Derived>& v, int start, int end)
{ {
return Eigen::VectorBlock<Derived>(v.derived(), start, end-start); return Eigen::VectorBlock<const Derived>(v.derived(), start, end-start);
} }
int main(int, char**) int main(int, char**)

View File

@ -4,7 +4,7 @@ cout << "Here is a random self-adjoint 4x4 matrix:" << endl << A << endl << endl
Tridiagonalization<MatrixXcd> triOfA(A); Tridiagonalization<MatrixXcd> triOfA(A);
MatrixXd T = triOfA.matrixT(); MatrixXd T = triOfA.matrixT();
cout << "The tridiagonal matrix T is:" << endl << triOfA.matrixT() << endl << endl; cout << "The tridiagonal matrix T is:" << endl << T << endl << endl;
cout << "We can also extract the diagonals of T directly ..." << endl; cout << "We can also extract the diagonals of T directly ..." << endl;
VectorXd diag = triOfA.diagonal(); VectorXd diag = triOfA.diagonal();