mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
the Index types change.
As discussed on the list (too long to explain here).
This commit is contained in:
@@ -68,8 +68,10 @@ class ei_companion
|
||||
typedef Matrix< Scalar, Deg_1, Deg_1 > BottomLeftBlock;
|
||||
typedef Matrix< Scalar, 1, Deg_1 > LeftBlockFirstRow;
|
||||
|
||||
typedef DenseIndex Index;
|
||||
|
||||
public:
|
||||
EIGEN_STRONG_INLINE const _Scalar operator()( int row, int col ) const
|
||||
EIGEN_STRONG_INLINE const _Scalar operator()(Index row, Index col ) const
|
||||
{
|
||||
if( m_bl_diag.rows() > col )
|
||||
{
|
||||
@@ -83,7 +85,7 @@ class ei_companion
|
||||
template<typename VectorType>
|
||||
void setPolynomial( const VectorType& poly )
|
||||
{
|
||||
const int deg = poly.size()-1;
|
||||
const Index deg = poly.size()-1;
|
||||
m_monic = -1/poly[deg] * poly.head(deg);
|
||||
//m_bl_diag.setIdentity( deg-1 );
|
||||
m_bl_diag.setOnes(deg-1);
|
||||
@@ -96,8 +98,8 @@ class ei_companion
|
||||
public:
|
||||
DenseCompanionMatrixType denseMatrix() const
|
||||
{
|
||||
const int deg = m_monic.size();
|
||||
const int deg_1 = deg-1;
|
||||
const Index deg = m_monic.size();
|
||||
const Index deg_1 = deg-1;
|
||||
DenseCompanionMatrixType companion(deg,deg);
|
||||
companion <<
|
||||
( LeftBlock(deg,deg_1)
|
||||
@@ -220,8 +222,8 @@ template< typename _Scalar, int _Deg >
|
||||
void ei_companion<_Scalar,_Deg>::balance()
|
||||
{
|
||||
EIGEN_STATIC_ASSERT( 1 < Deg, YOU_MADE_A_PROGRAMMING_MISTAKE );
|
||||
const int deg = m_monic.size();
|
||||
const int deg_1 = deg-1;
|
||||
const Index deg = m_monic.size();
|
||||
const Index deg_1 = deg-1;
|
||||
|
||||
bool hasConverged=false;
|
||||
while( !hasConverged )
|
||||
@@ -244,7 +246,7 @@ void ei_companion<_Scalar,_Deg>::balance()
|
||||
|
||||
//Middle rows and columns excluding the diagonal
|
||||
//==============================================
|
||||
for( int i=1; i<deg_1; ++i )
|
||||
for( Index i=1; i<deg_1; ++i )
|
||||
{
|
||||
// column norm, excluding the diagonal
|
||||
colNorm = ei_abs(m_bl_diag[i]);
|
||||
@@ -263,7 +265,7 @@ void ei_companion<_Scalar,_Deg>::balance()
|
||||
|
||||
//Last row, last column excluding the diagonal
|
||||
//============================================
|
||||
const int ebl = m_bl_diag.size()-1;
|
||||
const Index ebl = m_bl_diag.size()-1;
|
||||
VectorBlock<RightColumn,Deg_1> headMonic( m_monic, 0, deg_1 );
|
||||
colNorm = headMonic.array().abs().sum();
|
||||
rowNorm = ei_abs( m_bl_diag[ebl] );
|
||||
|
||||
@@ -49,6 +49,8 @@ class PolynomialSolverBase
|
||||
typedef std::complex<RealScalar> RootType;
|
||||
typedef Matrix<RootType,_Deg,1> RootsType;
|
||||
|
||||
typedef DenseIndex Index;
|
||||
|
||||
protected:
|
||||
template< typename OtherPolynomial >
|
||||
inline void setPolynomial( const OtherPolynomial& poly ){
|
||||
@@ -81,7 +83,7 @@ class PolynomialSolverBase
|
||||
const RealScalar& absImaginaryThreshold = NumTraits<Scalar>::dummy_precision() ) const
|
||||
{
|
||||
bi_seq.clear();
|
||||
for( int i=0; i<m_roots.size(); ++i )
|
||||
for(Index i=0; i<m_roots.size(); ++i )
|
||||
{
|
||||
if( ei_abs( m_roots[i].imag() ) < absImaginaryThreshold ){
|
||||
bi_seq.push_back( m_roots[i].real() ); }
|
||||
@@ -92,9 +94,9 @@ class PolynomialSolverBase
|
||||
template<typename squaredNormBinaryPredicate>
|
||||
inline const RootType& selectComplexRoot_withRespectToNorm( squaredNormBinaryPredicate& pred ) const
|
||||
{
|
||||
int res=0;
|
||||
Index res=0;
|
||||
RealScalar norm2 = ei_abs2( m_roots[0] );
|
||||
for( int i=1; i<m_roots.size(); ++i )
|
||||
for( Index i=1; i<m_roots.size(); ++i )
|
||||
{
|
||||
const RealScalar currNorm2 = ei_abs2( m_roots[i] );
|
||||
if( pred( currNorm2, norm2 ) ){
|
||||
@@ -130,10 +132,10 @@ class PolynomialSolverBase
|
||||
const RealScalar& absImaginaryThreshold = NumTraits<Scalar>::dummy_precision() ) const
|
||||
{
|
||||
hasArealRoot = false;
|
||||
int res=0;
|
||||
Index res=0;
|
||||
RealScalar abs2(0);
|
||||
|
||||
for( int i=0; i<m_roots.size(); ++i )
|
||||
for( Index i=0; i<m_roots.size(); ++i )
|
||||
{
|
||||
if( ei_abs( m_roots[i].imag() ) < absImaginaryThreshold )
|
||||
{
|
||||
@@ -170,10 +172,10 @@ class PolynomialSolverBase
|
||||
const RealScalar& absImaginaryThreshold = NumTraits<Scalar>::dummy_precision() ) const
|
||||
{
|
||||
hasArealRoot = false;
|
||||
int res=0;
|
||||
Index res=0;
|
||||
RealScalar val(0);
|
||||
|
||||
for( int i=0; i<m_roots.size(); ++i )
|
||||
for( Index i=0; i<m_roots.size(); ++i )
|
||||
{
|
||||
if( ei_abs( m_roots[i].imag() ) < absImaginaryThreshold )
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ inline
|
||||
T poly_eval_horner( const Polynomials& poly, const T& x )
|
||||
{
|
||||
T val=poly[poly.size()-1];
|
||||
for( int i=poly.size()-2; i>=0; --i ){
|
||||
for(DenseIndex i=poly.size()-2; i>=0; --i ){
|
||||
val = val*x + poly[i]; }
|
||||
return val;
|
||||
}
|
||||
@@ -66,7 +66,7 @@ T poly_eval( const Polynomials& poly, const T& x )
|
||||
{
|
||||
T val=poly[0];
|
||||
T inv_x = T(1)/x;
|
||||
for( int i=1; i<poly.size(); ++i ){
|
||||
for( DenseIndex i=1; i<poly.size(); ++i ){
|
||||
val = val*inv_x + poly[i]; }
|
||||
|
||||
return std::pow(x,(T)(poly.size()-1)) * val;
|
||||
@@ -94,7 +94,7 @@ typename NumTraits<typename Polynomial::Scalar>::Real cauchy_max_bound( const Po
|
||||
const Scalar inv_leading_coeff = Scalar(1)/poly[poly.size()-1];
|
||||
Real cb(0);
|
||||
|
||||
for( int i=0; i<poly.size()-1; ++i ){
|
||||
for( DenseIndex i=0; i<poly.size()-1; ++i ){
|
||||
cb += ei_abs(poly[i]*inv_leading_coeff); }
|
||||
return cb + Real(1);
|
||||
}
|
||||
@@ -112,14 +112,14 @@ typename NumTraits<typename Polynomial::Scalar>::Real cauchy_min_bound( const Po
|
||||
typedef typename Polynomial::Scalar Scalar;
|
||||
typedef typename NumTraits<Scalar>::Real Real;
|
||||
|
||||
int i=0;
|
||||
DenseIndex i=0;
|
||||
while( i<poly.size()-1 && Scalar(0) == poly(i) ){ ++i; }
|
||||
if( poly.size()-1 == i ){
|
||||
return Real(1); }
|
||||
|
||||
const Scalar inv_min_coeff = Scalar(1)/poly[i];
|
||||
Real cb(1);
|
||||
for( int j=i+1; j<poly.size(); ++j ){
|
||||
for( DenseIndex j=i+1; j<poly.size(); ++j ){
|
||||
cb += ei_abs(poly[j]*inv_min_coeff); }
|
||||
return Real(1)/cb;
|
||||
}
|
||||
@@ -142,9 +142,9 @@ void roots_to_monicPolynomial( const RootVector& rv, Polynomial& poly )
|
||||
|
||||
poly.setZero( rv.size()+1 );
|
||||
poly[0] = -rv[0]; poly[1] = Scalar(1);
|
||||
for( int i=1; i<(int)rv.size(); ++i )
|
||||
for( DenseIndex i=1; i< rv.size(); ++i )
|
||||
{
|
||||
for( int j=i+1; j>0; --j ){ poly[j] = poly[j-1] - rv[i]*poly[j]; }
|
||||
for( DenseIndex j=i+1; j>0; --j ){ poly[j] = poly[j-1] - rv[i]*poly[j]; }
|
||||
poly[0] = -rv[i]*poly[0];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user