mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-21 08:53:17 +08:00
fix bug #485: conflict between a typedef and template type parameter
This commit is contained in:
parent
269be00925
commit
46b1c7a0ce
@ -37,12 +37,13 @@ class DiagonalPreconditioner
|
|||||||
typedef typename Vector::Index Index;
|
typedef typename Vector::Index Index;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// this typedef is only to export the scalar type and compile-time dimensions to solve_retval
|
||||||
typedef Matrix<Scalar,Dynamic,Dynamic> MatrixType;
|
typedef Matrix<Scalar,Dynamic,Dynamic> MatrixType;
|
||||||
|
|
||||||
DiagonalPreconditioner() : m_isInitialized(false) {}
|
DiagonalPreconditioner() : m_isInitialized(false) {}
|
||||||
|
|
||||||
template<typename MatrixType>
|
template<typename MatType>
|
||||||
DiagonalPreconditioner(const MatrixType& mat) : m_invdiag(mat.cols())
|
DiagonalPreconditioner(const MatType& mat) : m_invdiag(mat.cols())
|
||||||
{
|
{
|
||||||
compute(mat);
|
compute(mat);
|
||||||
}
|
}
|
||||||
@ -50,19 +51,19 @@ class DiagonalPreconditioner
|
|||||||
Index rows() const { return m_invdiag.size(); }
|
Index rows() const { return m_invdiag.size(); }
|
||||||
Index cols() const { return m_invdiag.size(); }
|
Index cols() const { return m_invdiag.size(); }
|
||||||
|
|
||||||
template<typename MatrixType>
|
template<typename MatType>
|
||||||
DiagonalPreconditioner& analyzePattern(const MatrixType& )
|
DiagonalPreconditioner& analyzePattern(const MatType& )
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename MatrixType>
|
template<typename MatType>
|
||||||
DiagonalPreconditioner& factorize(const MatrixType& mat)
|
DiagonalPreconditioner& factorize(const MatType& mat)
|
||||||
{
|
{
|
||||||
m_invdiag.resize(mat.cols());
|
m_invdiag.resize(mat.cols());
|
||||||
for(int j=0; j<mat.outerSize(); ++j)
|
for(int j=0; j<mat.outerSize(); ++j)
|
||||||
{
|
{
|
||||||
typename MatrixType::InnerIterator it(mat,j);
|
typename MatType::InnerIterator it(mat,j);
|
||||||
while(it && it.index()!=j) ++it;
|
while(it && it.index()!=j) ++it;
|
||||||
if(it && it.index()==j)
|
if(it && it.index()==j)
|
||||||
m_invdiag(j) = Scalar(1)/it.value();
|
m_invdiag(j) = Scalar(1)/it.value();
|
||||||
@ -73,8 +74,8 @@ class DiagonalPreconditioner
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename MatrixType>
|
template<typename MatType>
|
||||||
DiagonalPreconditioner& compute(const MatrixType& mat)
|
DiagonalPreconditioner& compute(const MatType& mat)
|
||||||
{
|
{
|
||||||
return factorize(mat);
|
return factorize(mat);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user