mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
bug #86 : use internal:: namespace instead of ei_ prefix
This commit is contained in:
@@ -31,14 +31,16 @@
|
||||
|
||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||
|
||||
template <typename T>
|
||||
T ei_radix(){ return 2; }
|
||||
namespace internal {
|
||||
|
||||
template <typename T>
|
||||
T ei_radix2(){ return ei_radix<T>()*ei_radix<T>(); }
|
||||
T radix(){ return 2; }
|
||||
|
||||
template <typename T>
|
||||
T radix2(){ return radix<T>()*radix<T>(); }
|
||||
|
||||
template<int Size>
|
||||
struct ei_decrement_if_fixed_size
|
||||
struct decrement_if_fixed_size
|
||||
{
|
||||
enum {
|
||||
ret = (Size == Dynamic) ? Dynamic : Size-1 };
|
||||
@@ -47,14 +49,14 @@ struct ei_decrement_if_fixed_size
|
||||
#endif
|
||||
|
||||
template< typename _Scalar, int _Deg >
|
||||
class ei_companion
|
||||
class companion
|
||||
{
|
||||
public:
|
||||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_Deg==Dynamic ? Dynamic : _Deg)
|
||||
|
||||
enum {
|
||||
Deg = _Deg,
|
||||
Deg_1=ei_decrement_if_fixed_size<Deg>::ret
|
||||
Deg_1=decrement_if_fixed_size<Deg>::ret
|
||||
};
|
||||
|
||||
typedef _Scalar Scalar;
|
||||
@@ -92,7 +94,7 @@ class ei_companion
|
||||
}
|
||||
|
||||
template<typename VectorType>
|
||||
ei_companion( const VectorType& poly ){
|
||||
companion( const VectorType& poly ){
|
||||
setPolynomial( poly ); }
|
||||
|
||||
public:
|
||||
@@ -150,7 +152,7 @@ class ei_companion
|
||||
|
||||
template< typename _Scalar, int _Deg >
|
||||
inline
|
||||
bool ei_companion<_Scalar,_Deg>::balanced( Scalar colNorm, Scalar rowNorm,
|
||||
bool companion<_Scalar,_Deg>::balanced( Scalar colNorm, Scalar rowNorm,
|
||||
bool& isBalanced, Scalar& colB, Scalar& rowB )
|
||||
{
|
||||
if( Scalar(0) == colNorm || Scalar(0) == rowNorm ){ return true; }
|
||||
@@ -161,22 +163,22 @@ bool ei_companion<_Scalar,_Deg>::balanced( Scalar colNorm, Scalar rowNorm,
|
||||
// \f$ 2^{2\sigma-1} < rowNorm / colNorm \le 2^{2\sigma+1} \f$
|
||||
// then the balancing coefficient for the row is \f$ 1/2^{\sigma} \f$
|
||||
// and the balancing coefficient for the column is \f$ 2^{\sigma} \f$
|
||||
rowB = rowNorm / ei_radix<Scalar>();
|
||||
rowB = rowNorm / radix<Scalar>();
|
||||
colB = Scalar(1);
|
||||
const Scalar s = colNorm + rowNorm;
|
||||
|
||||
while (colNorm < rowB)
|
||||
{
|
||||
colB *= ei_radix<Scalar>();
|
||||
colNorm *= ei_radix2<Scalar>();
|
||||
colB *= radix<Scalar>();
|
||||
colNorm *= radix2<Scalar>();
|
||||
}
|
||||
|
||||
rowB = rowNorm * ei_radix<Scalar>();
|
||||
rowB = rowNorm * radix<Scalar>();
|
||||
|
||||
while (colNorm >= rowB)
|
||||
{
|
||||
colB /= ei_radix<Scalar>();
|
||||
colNorm /= ei_radix2<Scalar>();
|
||||
colB /= radix<Scalar>();
|
||||
colNorm /= radix2<Scalar>();
|
||||
}
|
||||
|
||||
//This line is used to avoid insubstantial balancing
|
||||
@@ -193,7 +195,7 @@ bool ei_companion<_Scalar,_Deg>::balanced( Scalar colNorm, Scalar rowNorm,
|
||||
|
||||
template< typename _Scalar, int _Deg >
|
||||
inline
|
||||
bool ei_companion<_Scalar,_Deg>::balancedR( Scalar colNorm, Scalar rowNorm,
|
||||
bool companion<_Scalar,_Deg>::balancedR( Scalar colNorm, Scalar rowNorm,
|
||||
bool& isBalanced, Scalar& colB, Scalar& rowB )
|
||||
{
|
||||
if( Scalar(0) == colNorm || Scalar(0) == rowNorm ){ return true; }
|
||||
@@ -204,9 +206,9 @@ bool ei_companion<_Scalar,_Deg>::balancedR( Scalar colNorm, Scalar rowNorm,
|
||||
* of the row and column norm
|
||||
*/
|
||||
const _Scalar q = colNorm/rowNorm;
|
||||
if( !ei_isApprox( q, _Scalar(1) ) )
|
||||
if( !isApprox( q, _Scalar(1) ) )
|
||||
{
|
||||
rowB = ei_sqrt( colNorm/rowNorm );
|
||||
rowB = sqrt( colNorm/rowNorm );
|
||||
colB = Scalar(1)/rowB;
|
||||
|
||||
isBalanced = false;
|
||||
@@ -219,7 +221,7 @@ bool ei_companion<_Scalar,_Deg>::balancedR( Scalar colNorm, Scalar rowNorm,
|
||||
|
||||
|
||||
template< typename _Scalar, int _Deg >
|
||||
void ei_companion<_Scalar,_Deg>::balance()
|
||||
void companion<_Scalar,_Deg>::balance()
|
||||
{
|
||||
EIGEN_STATIC_ASSERT( Deg == Dynamic || 1 < Deg, YOU_MADE_A_PROGRAMMING_MISTAKE );
|
||||
const Index deg = m_monic.size();
|
||||
@@ -234,8 +236,8 @@ void ei_companion<_Scalar,_Deg>::balance()
|
||||
|
||||
//First row, first column excluding the diagonal
|
||||
//==============================================
|
||||
colNorm = ei_abs(m_bl_diag[0]);
|
||||
rowNorm = ei_abs(m_monic[0]);
|
||||
colNorm = abs(m_bl_diag[0]);
|
||||
rowNorm = abs(m_monic[0]);
|
||||
|
||||
//Compute balancing of the row and the column
|
||||
if( !balanced( colNorm, rowNorm, hasConverged, colB, rowB ) )
|
||||
@@ -249,10 +251,10 @@ void ei_companion<_Scalar,_Deg>::balance()
|
||||
for( Index i=1; i<deg_1; ++i )
|
||||
{
|
||||
// column norm, excluding the diagonal
|
||||
colNorm = ei_abs(m_bl_diag[i]);
|
||||
colNorm = abs(m_bl_diag[i]);
|
||||
|
||||
// row norm, excluding the diagonal
|
||||
rowNorm = ei_abs(m_bl_diag[i-1]) + ei_abs(m_monic[i]);
|
||||
rowNorm = abs(m_bl_diag[i-1]) + abs(m_monic[i]);
|
||||
|
||||
//Compute balancing of the row and the column
|
||||
if( !balanced( colNorm, rowNorm, hasConverged, colB, rowB ) )
|
||||
@@ -268,7 +270,7 @@ void ei_companion<_Scalar,_Deg>::balance()
|
||||
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] );
|
||||
rowNorm = abs( m_bl_diag[ebl] );
|
||||
|
||||
//Compute balancing of the row and the column
|
||||
if( !balanced( colNorm, rowNorm, hasConverged, colB, rowB ) )
|
||||
@@ -279,5 +281,6 @@ void ei_companion<_Scalar,_Deg>::balance()
|
||||
}
|
||||
}
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
#endif // EIGEN_COMPANION_H
|
||||
|
||||
@@ -85,7 +85,7 @@ class PolynomialSolverBase
|
||||
bi_seq.clear();
|
||||
for(Index i=0; i<m_roots.size(); ++i )
|
||||
{
|
||||
if( ei_abs( m_roots[i].imag() ) < absImaginaryThreshold ){
|
||||
if( internal::abs( m_roots[i].imag() ) < absImaginaryThreshold ){
|
||||
bi_seq.push_back( m_roots[i].real() ); }
|
||||
}
|
||||
}
|
||||
@@ -95,10 +95,10 @@ class PolynomialSolverBase
|
||||
inline const RootType& selectComplexRoot_withRespectToNorm( squaredNormBinaryPredicate& pred ) const
|
||||
{
|
||||
Index res=0;
|
||||
RealScalar norm2 = ei_abs2( m_roots[0] );
|
||||
RealScalar norm2 = internal::abs2( m_roots[0] );
|
||||
for( Index i=1; i<m_roots.size(); ++i )
|
||||
{
|
||||
const RealScalar currNorm2 = ei_abs2( m_roots[i] );
|
||||
const RealScalar currNorm2 = internal::abs2( m_roots[i] );
|
||||
if( pred( currNorm2, norm2 ) ){
|
||||
res=i; norm2=currNorm2; }
|
||||
}
|
||||
@@ -137,7 +137,7 @@ class PolynomialSolverBase
|
||||
|
||||
for( Index i=0; i<m_roots.size(); ++i )
|
||||
{
|
||||
if( ei_abs( m_roots[i].imag() ) < absImaginaryThreshold )
|
||||
if( internal::abs( m_roots[i].imag() ) < absImaginaryThreshold )
|
||||
{
|
||||
if( !hasArealRoot )
|
||||
{
|
||||
@@ -157,11 +157,11 @@ class PolynomialSolverBase
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ei_abs( m_roots[i].imag() ) < ei_abs( m_roots[res].imag() ) ){
|
||||
if( internal::abs( m_roots[i].imag() ) < internal::abs( m_roots[res].imag() ) ){
|
||||
res = i; }
|
||||
}
|
||||
}
|
||||
return ei_real_ref(m_roots[res]);
|
||||
return internal::real_ref(m_roots[res]);
|
||||
}
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ class PolynomialSolverBase
|
||||
|
||||
for( Index i=0; i<m_roots.size(); ++i )
|
||||
{
|
||||
if( ei_abs( m_roots[i].imag() ) < absImaginaryThreshold )
|
||||
if( internal::abs( m_roots[i].imag() ) < absImaginaryThreshold )
|
||||
{
|
||||
if( !hasArealRoot )
|
||||
{
|
||||
@@ -197,11 +197,11 @@ class PolynomialSolverBase
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ei_abs( m_roots[i].imag() ) < ei_abs( m_roots[res].imag() ) ){
|
||||
if( internal::abs( m_roots[i].imag() ) < internal::abs( m_roots[res].imag() ) ){
|
||||
res = i; }
|
||||
}
|
||||
}
|
||||
return ei_real_ref(m_roots[res]);
|
||||
return internal::real_ref(m_roots[res]);
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -355,7 +355,7 @@ class PolynomialSolver : public PolynomialSolverBase<_Scalar,_Deg>
|
||||
void compute( const OtherPolynomial& poly )
|
||||
{
|
||||
assert( Scalar(0) != poly[poly.size()-1] );
|
||||
ei_companion<Scalar,_Deg> companion( poly );
|
||||
internal::companion<Scalar,_Deg> companion( poly );
|
||||
companion.balance();
|
||||
m_eigenSolver.compute( companion.denseMatrix() );
|
||||
m_roots = m_eigenSolver.eigenvalues();
|
||||
|
||||
@@ -60,7 +60,7 @@ T poly_eval( const Polynomials& poly, const T& x )
|
||||
{
|
||||
typedef typename NumTraits<T>::Real Real;
|
||||
|
||||
if( ei_abs2( x ) <= Real(1) ){
|
||||
if( internal::abs2( x ) <= Real(1) ){
|
||||
return poly_eval_horner( poly, x ); }
|
||||
else
|
||||
{
|
||||
@@ -95,7 +95,7 @@ typename NumTraits<typename Polynomial::Scalar>::Real cauchy_max_bound( const Po
|
||||
Real cb(0);
|
||||
|
||||
for( DenseIndex i=0; i<poly.size()-1; ++i ){
|
||||
cb += ei_abs(poly[i]*inv_leading_coeff); }
|
||||
cb += internal::abs(poly[i]*inv_leading_coeff); }
|
||||
return cb + Real(1);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ typename NumTraits<typename Polynomial::Scalar>::Real cauchy_min_bound( const Po
|
||||
const Scalar inv_min_coeff = Scalar(1)/poly[i];
|
||||
Real cb(1);
|
||||
for( DenseIndex j=i+1; j<poly.size(); ++j ){
|
||||
cb += ei_abs(poly[j]*inv_min_coeff); }
|
||||
cb += internal::abs(poly[j]*inv_min_coeff); }
|
||||
return Real(1)/cb;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user