mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Fix bug #314:
- remove most of the metaprogramming kung fu in MathFunctions.h (only keep functions that differs from the std) - remove the overloads for array expression that were in the std namespace
This commit is contained in:
@@ -167,7 +167,8 @@ template<typename _Scalar> class AlignedVector3
|
||||
|
||||
inline Scalar norm() const
|
||||
{
|
||||
return internal::sqrt(squaredNorm());
|
||||
using std::sqrt;
|
||||
return sqrt(squaredNorm());
|
||||
}
|
||||
|
||||
inline AlignedVector3 cross(const AlignedVector3& other) const
|
||||
|
||||
@@ -28,6 +28,7 @@ struct kiss_cpx_fft
|
||||
inline
|
||||
void make_twiddles(int nfft,bool inverse)
|
||||
{
|
||||
using std::acos;
|
||||
m_inverse = inverse;
|
||||
m_twiddles.resize(nfft);
|
||||
Scalar phinc = (inverse?2:-2)* acos( (Scalar) -1) / nfft;
|
||||
@@ -399,6 +400,7 @@ struct kissfft_impl
|
||||
inline
|
||||
Complex * real_twiddles(int ncfft2)
|
||||
{
|
||||
using std::acos;
|
||||
std::vector<Complex> & twidref = m_realTwiddles[ncfft2];// creates new if not there
|
||||
if ( (int)twidref.size() != ncfft2 ) {
|
||||
twidref.resize(ncfft2);
|
||||
|
||||
@@ -116,6 +116,7 @@ template<typename Scalar, int _UpLo, typename OrderingType>
|
||||
template<typename _MatrixType>
|
||||
void IncompleteCholesky<Scalar,_UpLo, OrderingType>::factorize(const _MatrixType& mat)
|
||||
{
|
||||
using std::sqrt;
|
||||
eigen_assert(m_analysisIsOk && "analyzePattern() should be called first");
|
||||
|
||||
// FIXME Stability: We should probably compute the scaling factors and the shifts that are needed to ensure a succesful LLT factorization and an efficient preconditioner.
|
||||
@@ -182,7 +183,7 @@ void IncompleteCholesky<Scalar,_UpLo, OrderingType>::factorize(const _MatrixType
|
||||
m_info = NumericalIssue;
|
||||
return;
|
||||
}
|
||||
RealScalar rdiag = internal::sqrt(RealScalar(diag));
|
||||
RealScalar rdiag = sqrt(RealScalar(diag));
|
||||
Scalar scal = Scalar(1)/rdiag;
|
||||
vals[colPtr[j]] = rdiag;
|
||||
// Insert the largest p elements in the matrix and scale them meanwhile
|
||||
|
||||
@@ -129,7 +129,8 @@ class IterationController
|
||||
bool converged() const { return m_res <= m_rhsn * m_resmax; }
|
||||
bool converged(double nr)
|
||||
{
|
||||
m_res = internal::abs(nr);
|
||||
using std::abs;
|
||||
m_res = abs(nr);
|
||||
m_resminreach = (std::min)(m_resminreach, m_res);
|
||||
return converged();
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Eigen {
|
||||
const Preconditioner& precond, int& iters,
|
||||
typename Dest::RealScalar& tol_error)
|
||||
{
|
||||
using std::sqrt;
|
||||
typedef typename Dest::RealScalar RealScalar;
|
||||
typedef typename Dest::Scalar Scalar;
|
||||
typedef Matrix<Scalar,Dynamic,1> VectorType;
|
||||
|
||||
@@ -235,6 +235,7 @@ void MatrixFunction<MatrixType,AtomicType,1>::computeSchurDecomposition()
|
||||
template <typename MatrixType, typename AtomicType>
|
||||
void MatrixFunction<MatrixType,AtomicType,1>::partitionEigenvalues()
|
||||
{
|
||||
using std::abs;
|
||||
const Index rows = m_T.rows();
|
||||
VectorType diag = m_T.diagonal(); // contains eigenvalues of A
|
||||
|
||||
@@ -251,14 +252,14 @@ void MatrixFunction<MatrixType,AtomicType,1>::partitionEigenvalues()
|
||||
|
||||
// Look for other element to add to the set
|
||||
for (Index j=i+1; j<rows; ++j) {
|
||||
if (internal::abs(diag(j) - diag(i)) <= separation() && std::find(qi->begin(), qi->end(), diag(j)) == qi->end()) {
|
||||
typename ListOfClusters::iterator qj = findCluster(diag(j));
|
||||
if (qj == m_clusters.end()) {
|
||||
qi->push_back(diag(j));
|
||||
} else {
|
||||
qi->insert(qi->end(), qj->begin(), qj->end());
|
||||
m_clusters.erase(qj);
|
||||
}
|
||||
if (abs(diag(j) - diag(i)) <= separation() && std::find(qi->begin(), qi->end(), diag(j)) == qi->end()) {
|
||||
typename ListOfClusters::iterator qj = findCluster(diag(j));
|
||||
if (qj == m_clusters.end()) {
|
||||
qi->push_back(diag(j));
|
||||
} else {
|
||||
qi->insert(qi->end(), qj->begin(), qj->end());
|
||||
m_clusters.erase(qj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +125,7 @@ void MatrixLogarithmAtomic<MatrixType>::compute2x2(const MatrixType& A, MatrixTy
|
||||
template <typename MatrixType>
|
||||
void MatrixLogarithmAtomic<MatrixType>::computeBig(const MatrixType& A, MatrixType& result)
|
||||
{
|
||||
using std::pow;
|
||||
int numberOfSquareRoots = 0;
|
||||
int numberOfExtraSquareRoots = 0;
|
||||
int degree;
|
||||
@@ -141,7 +142,7 @@ void MatrixLogarithmAtomic<MatrixType>::computeBig(const MatrixType& A, MatrixTy
|
||||
degree = getPadeDegree(normTminusI);
|
||||
int degree2 = getPadeDegree(normTminusI / RealScalar(2));
|
||||
if ((degree - degree2 <= 1) || (numberOfExtraSquareRoots == 1))
|
||||
break;
|
||||
break;
|
||||
++numberOfExtraSquareRoots;
|
||||
}
|
||||
MatrixType sqrtT;
|
||||
|
||||
@@ -99,11 +99,12 @@ template <typename MatrixType>
|
||||
void MatrixSquareRootQuasiTriangular<MatrixType>::computeDiagonalPartOfSqrt(MatrixType& sqrtT,
|
||||
const MatrixType& T)
|
||||
{
|
||||
using std::sqrt;
|
||||
const Index size = m_A.rows();
|
||||
for (Index i = 0; i < size; i++) {
|
||||
if (i == size - 1 || T.coeff(i+1, i) == 0) {
|
||||
eigen_assert(T(i,i) > 0);
|
||||
sqrtT.coeffRef(i,i) = internal::sqrt(T.coeff(i,i));
|
||||
sqrtT.coeffRef(i,i) = sqrt(T.coeff(i,i));
|
||||
}
|
||||
else {
|
||||
compute2x2diagonalBlock(sqrtT, T, i);
|
||||
@@ -289,6 +290,7 @@ template <typename MatrixType>
|
||||
template <typename ResultType>
|
||||
void MatrixSquareRootTriangular<MatrixType>::compute(ResultType &result)
|
||||
{
|
||||
using std::sqrt;
|
||||
// Compute Schur decomposition of m_A
|
||||
const ComplexSchur<MatrixType> schurOfA(m_A);
|
||||
const MatrixType& T = schurOfA.matrixT();
|
||||
@@ -299,7 +301,7 @@ void MatrixSquareRootTriangular<MatrixType>::compute(ResultType &result)
|
||||
result.resize(m_A.rows(), m_A.cols());
|
||||
typedef typename MatrixType::Index Index;
|
||||
for (Index i = 0; i < m_A.rows(); i++) {
|
||||
result.coeffRef(i,i) = internal::sqrt(T.coeff(i,i));
|
||||
result.coeffRef(i,i) = sqrt(T.coeff(i,i));
|
||||
}
|
||||
for (Index j = 1; j < m_A.cols(); j++) {
|
||||
for (Index i = j-1; i >= 0; i--) {
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
Parameters()
|
||||
: factor(Scalar(100.))
|
||||
, maxfev(1000)
|
||||
, xtol(internal::sqrt(NumTraits<Scalar>::epsilon()))
|
||||
, xtol(std::sqrt(NumTraits<Scalar>::epsilon()))
|
||||
, nb_of_subdiagonals(-1)
|
||||
, nb_of_superdiagonals(-1)
|
||||
, epsfcn(Scalar(0.)) {}
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
|
||||
HybridNonLinearSolverSpace::Status hybrj1(
|
||||
FVectorType &x,
|
||||
const Scalar tol = internal::sqrt(NumTraits<Scalar>::epsilon())
|
||||
const Scalar tol = std::sqrt(NumTraits<Scalar>::epsilon())
|
||||
);
|
||||
|
||||
HybridNonLinearSolverSpace::Status solveInit(FVectorType &x);
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
|
||||
HybridNonLinearSolverSpace::Status hybrd1(
|
||||
FVectorType &x,
|
||||
const Scalar tol = internal::sqrt(NumTraits<Scalar>::epsilon())
|
||||
const Scalar tol = std::sqrt(NumTraits<Scalar>::epsilon())
|
||||
);
|
||||
|
||||
HybridNonLinearSolverSpace::Status solveNumericalDiffInit(FVectorType &x);
|
||||
@@ -185,6 +185,8 @@ template<typename FunctorType, typename Scalar>
|
||||
HybridNonLinearSolverSpace::Status
|
||||
HybridNonLinearSolver<FunctorType,Scalar>::solveOneStep(FVectorType &x)
|
||||
{
|
||||
using std::abs;
|
||||
|
||||
assert(x.size()==n); // check the caller is not cheating us
|
||||
|
||||
Index j;
|
||||
@@ -276,7 +278,7 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveOneStep(FVectorType &x)
|
||||
++ncsuc;
|
||||
if (ratio >= Scalar(.5) || ncsuc > 1)
|
||||
delta = (std::max)(delta, pnorm / Scalar(.5));
|
||||
if (internal::abs(ratio - 1.) <= Scalar(.1)) {
|
||||
if (abs(ratio - 1.) <= Scalar(.1)) {
|
||||
delta = pnorm / Scalar(.5);
|
||||
}
|
||||
}
|
||||
@@ -423,6 +425,9 @@ template<typename FunctorType, typename Scalar>
|
||||
HybridNonLinearSolverSpace::Status
|
||||
HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiffOneStep(FVectorType &x)
|
||||
{
|
||||
using std::sqrt;
|
||||
using std::abs;
|
||||
|
||||
assert(x.size()==n); // check the caller is not cheating us
|
||||
|
||||
Index j;
|
||||
@@ -516,7 +521,7 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiffOneStep(FVectorType
|
||||
++ncsuc;
|
||||
if (ratio >= Scalar(.5) || ncsuc > 1)
|
||||
delta = (std::max)(delta, pnorm / Scalar(.5));
|
||||
if (internal::abs(ratio - 1.) <= Scalar(.1)) {
|
||||
if (abs(ratio - 1.) <= Scalar(.1)) {
|
||||
delta = pnorm / Scalar(.5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ public:
|
||||
Parameters()
|
||||
: factor(Scalar(100.))
|
||||
, maxfev(400)
|
||||
, ftol(internal::sqrt(NumTraits<Scalar>::epsilon()))
|
||||
, xtol(internal::sqrt(NumTraits<Scalar>::epsilon()))
|
||||
, ftol(std::sqrt(NumTraits<Scalar>::epsilon()))
|
||||
, xtol(std::sqrt(NumTraits<Scalar>::epsilon()))
|
||||
, gtol(Scalar(0.))
|
||||
, epsfcn(Scalar(0.)) {}
|
||||
Scalar factor;
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
|
||||
LevenbergMarquardtSpace::Status lmder1(
|
||||
FVectorType &x,
|
||||
const Scalar tol = internal::sqrt(NumTraits<Scalar>::epsilon())
|
||||
const Scalar tol = std::sqrt(NumTraits<Scalar>::epsilon())
|
||||
);
|
||||
|
||||
LevenbergMarquardtSpace::Status minimize(FVectorType &x);
|
||||
@@ -83,12 +83,12 @@ public:
|
||||
FunctorType &functor,
|
||||
FVectorType &x,
|
||||
Index *nfev,
|
||||
const Scalar tol = internal::sqrt(NumTraits<Scalar>::epsilon())
|
||||
const Scalar tol = std::sqrt(NumTraits<Scalar>::epsilon())
|
||||
);
|
||||
|
||||
LevenbergMarquardtSpace::Status lmstr1(
|
||||
FVectorType &x,
|
||||
const Scalar tol = internal::sqrt(NumTraits<Scalar>::epsilon())
|
||||
const Scalar tol = std::sqrt(NumTraits<Scalar>::epsilon())
|
||||
);
|
||||
|
||||
LevenbergMarquardtSpace::Status minimizeOptimumStorage(FVectorType &x);
|
||||
@@ -206,6 +206,9 @@ template<typename FunctorType, typename Scalar>
|
||||
LevenbergMarquardtSpace::Status
|
||||
LevenbergMarquardt<FunctorType,Scalar>::minimizeOneStep(FVectorType &x)
|
||||
{
|
||||
using std::abs;
|
||||
using std::sqrt;
|
||||
|
||||
assert(x.size()==n); // check the caller is not cheating us
|
||||
|
||||
/* calculate the jacobian matrix. */
|
||||
@@ -249,7 +252,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOneStep(FVectorType &x)
|
||||
if (fnorm != 0.)
|
||||
for (Index j = 0; j < n; ++j)
|
||||
if (wa2[permutation.indices()[j]] != 0.)
|
||||
gnorm = (std::max)(gnorm, internal::abs( fjac.col(j).head(j+1).dot(qtf.head(j+1)/fnorm) / wa2[permutation.indices()[j]]));
|
||||
gnorm = (std::max)(gnorm, abs( fjac.col(j).head(j+1).dot(qtf.head(j+1)/fnorm) / wa2[permutation.indices()[j]]));
|
||||
|
||||
/* test for convergence of the gradient norm. */
|
||||
if (gnorm <= parameters.gtol)
|
||||
@@ -288,7 +291,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOneStep(FVectorType &x)
|
||||
/* the scaled directional derivative. */
|
||||
wa3 = fjac.template triangularView<Upper>() * (qrfac.colsPermutation().inverse() *wa1);
|
||||
temp1 = internal::abs2(wa3.stableNorm() / fnorm);
|
||||
temp2 = internal::abs2(internal::sqrt(par) * pnorm / fnorm);
|
||||
temp2 = internal::abs2(sqrt(par) * pnorm / fnorm);
|
||||
prered = temp1 + temp2 / Scalar(.5);
|
||||
dirder = -(temp1 + temp2);
|
||||
|
||||
@@ -326,9 +329,9 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOneStep(FVectorType &x)
|
||||
}
|
||||
|
||||
/* tests for convergence. */
|
||||
if (internal::abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1. && delta <= parameters.xtol * xnorm)
|
||||
if (abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1. && delta <= parameters.xtol * xnorm)
|
||||
return LevenbergMarquardtSpace::RelativeErrorAndReductionTooSmall;
|
||||
if (internal::abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1.)
|
||||
if (abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1.)
|
||||
return LevenbergMarquardtSpace::RelativeReductionTooSmall;
|
||||
if (delta <= parameters.xtol * xnorm)
|
||||
return LevenbergMarquardtSpace::RelativeErrorTooSmall;
|
||||
@@ -336,7 +339,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOneStep(FVectorType &x)
|
||||
/* tests for termination and stringent tolerances. */
|
||||
if (nfev >= parameters.maxfev)
|
||||
return LevenbergMarquardtSpace::TooManyFunctionEvaluation;
|
||||
if (internal::abs(actred) <= NumTraits<Scalar>::epsilon() && prered <= NumTraits<Scalar>::epsilon() && Scalar(.5) * ratio <= 1.)
|
||||
if (abs(actred) <= NumTraits<Scalar>::epsilon() && prered <= NumTraits<Scalar>::epsilon() && Scalar(.5) * ratio <= 1.)
|
||||
return LevenbergMarquardtSpace::FtolTooSmall;
|
||||
if (delta <= NumTraits<Scalar>::epsilon() * xnorm)
|
||||
return LevenbergMarquardtSpace::XtolTooSmall;
|
||||
@@ -423,6 +426,9 @@ template<typename FunctorType, typename Scalar>
|
||||
LevenbergMarquardtSpace::Status
|
||||
LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorageOneStep(FVectorType &x)
|
||||
{
|
||||
using std::abs;
|
||||
using std::sqrt;
|
||||
|
||||
assert(x.size()==n); // check the caller is not cheating us
|
||||
|
||||
Index i, j;
|
||||
@@ -496,7 +502,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorageOneStep(FVectorTyp
|
||||
if (fnorm != 0.)
|
||||
for (j = 0; j < n; ++j)
|
||||
if (wa2[permutation.indices()[j]] != 0.)
|
||||
gnorm = (std::max)(gnorm, internal::abs( fjac.col(j).head(j+1).dot(qtf.head(j+1)/fnorm) / wa2[permutation.indices()[j]]));
|
||||
gnorm = (std::max)(gnorm, abs( fjac.col(j).head(j+1).dot(qtf.head(j+1)/fnorm) / wa2[permutation.indices()[j]]));
|
||||
|
||||
/* test for convergence of the gradient norm. */
|
||||
if (gnorm <= parameters.gtol)
|
||||
@@ -535,7 +541,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorageOneStep(FVectorTyp
|
||||
/* the scaled directional derivative. */
|
||||
wa3 = fjac.topLeftCorner(n,n).template triangularView<Upper>() * (permutation.inverse() * wa1);
|
||||
temp1 = internal::abs2(wa3.stableNorm() / fnorm);
|
||||
temp2 = internal::abs2(internal::sqrt(par) * pnorm / fnorm);
|
||||
temp2 = internal::abs2(sqrt(par) * pnorm / fnorm);
|
||||
prered = temp1 + temp2 / Scalar(.5);
|
||||
dirder = -(temp1 + temp2);
|
||||
|
||||
@@ -573,9 +579,9 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorageOneStep(FVectorTyp
|
||||
}
|
||||
|
||||
/* tests for convergence. */
|
||||
if (internal::abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1. && delta <= parameters.xtol * xnorm)
|
||||
if (abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1. && delta <= parameters.xtol * xnorm)
|
||||
return LevenbergMarquardtSpace::RelativeErrorAndReductionTooSmall;
|
||||
if (internal::abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1.)
|
||||
if (abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1.)
|
||||
return LevenbergMarquardtSpace::RelativeReductionTooSmall;
|
||||
if (delta <= parameters.xtol * xnorm)
|
||||
return LevenbergMarquardtSpace::RelativeErrorTooSmall;
|
||||
@@ -583,7 +589,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorageOneStep(FVectorTyp
|
||||
/* tests for termination and stringent tolerances. */
|
||||
if (nfev >= parameters.maxfev)
|
||||
return LevenbergMarquardtSpace::TooManyFunctionEvaluation;
|
||||
if (internal::abs(actred) <= NumTraits<Scalar>::epsilon() && prered <= NumTraits<Scalar>::epsilon() && Scalar(.5) * ratio <= 1.)
|
||||
if (abs(actred) <= NumTraits<Scalar>::epsilon() && prered <= NumTraits<Scalar>::epsilon() && Scalar(.5) * ratio <= 1.)
|
||||
return LevenbergMarquardtSpace::FtolTooSmall;
|
||||
if (delta <= NumTraits<Scalar>::epsilon() * xnorm)
|
||||
return LevenbergMarquardtSpace::XtolTooSmall;
|
||||
|
||||
@@ -16,6 +16,10 @@ void chkder(
|
||||
Matrix< Scalar, Dynamic, 1 > &err
|
||||
)
|
||||
{
|
||||
using std::sqrt;
|
||||
using std::abs;
|
||||
using std::log;
|
||||
|
||||
typedef DenseIndex Index;
|
||||
|
||||
const Scalar eps = sqrt(NumTraits<Scalar>::epsilon());
|
||||
|
||||
@@ -6,8 +6,9 @@ template <typename Scalar>
|
||||
void covar(
|
||||
Matrix< Scalar, Dynamic, Dynamic > &r,
|
||||
const VectorXi &ipvt,
|
||||
Scalar tol = sqrt(NumTraits<Scalar>::epsilon()) )
|
||||
Scalar tol = std::sqrt(NumTraits<Scalar>::epsilon()) )
|
||||
{
|
||||
using std::abs;
|
||||
typedef DenseIndex Index;
|
||||
|
||||
/* Local variables */
|
||||
|
||||
@@ -10,6 +10,9 @@ void dogleg(
|
||||
Scalar delta,
|
||||
Matrix< Scalar, Dynamic, 1 > &x)
|
||||
{
|
||||
using std::abs;
|
||||
using std::sqrt;
|
||||
|
||||
typedef DenseIndex Index;
|
||||
|
||||
/* Local variables */
|
||||
|
||||
@@ -11,6 +11,9 @@ DenseIndex fdjac1(
|
||||
DenseIndex ml, DenseIndex mu,
|
||||
Scalar epsfcn)
|
||||
{
|
||||
using std::sqrt;
|
||||
using std::abs;
|
||||
|
||||
typedef DenseIndex Index;
|
||||
|
||||
/* Local variables */
|
||||
|
||||
@@ -12,6 +12,8 @@ void lmpar(
|
||||
Scalar &par,
|
||||
Matrix< Scalar, Dynamic, 1 > &x)
|
||||
{
|
||||
using std::abs;
|
||||
using std::sqrt;
|
||||
typedef DenseIndex Index;
|
||||
|
||||
/* Local variables */
|
||||
@@ -168,6 +170,8 @@ void lmpar2(
|
||||
Matrix< Scalar, Dynamic, 1 > &x)
|
||||
|
||||
{
|
||||
using std::sqrt;
|
||||
using std::abs;
|
||||
typedef DenseIndex Index;
|
||||
|
||||
/* Local variables */
|
||||
|
||||
@@ -63,11 +63,13 @@ public:
|
||||
*/
|
||||
int df(const InputType& _x, JacobianType &jac) const
|
||||
{
|
||||
using std::sqrt;
|
||||
using std::abs;
|
||||
/* Local variables */
|
||||
Scalar h;
|
||||
int nfev=0;
|
||||
const typename InputType::Index n = _x.size();
|
||||
const Scalar eps = internal::sqrt(((std::max)(epsfcn,NumTraits<Scalar>::epsilon() )));
|
||||
const Scalar eps = sqrt(((std::max)(epsfcn,NumTraits<Scalar>::epsilon() )));
|
||||
ValueType val1, val2;
|
||||
InputType x = _x;
|
||||
// TODO : we should do this only if the size is not already known
|
||||
@@ -89,7 +91,7 @@ public:
|
||||
|
||||
// Function Body
|
||||
for (int j = 0; j < n; ++j) {
|
||||
h = eps * internal::abs(x[j]);
|
||||
h = eps * abs(x[j]);
|
||||
if (h == 0.) {
|
||||
h = eps;
|
||||
}
|
||||
|
||||
@@ -210,6 +210,7 @@ bool companion<_Scalar,_Deg>::balancedR( Scalar colNorm, Scalar rowNorm,
|
||||
template< typename _Scalar, int _Deg >
|
||||
void companion<_Scalar,_Deg>::balance()
|
||||
{
|
||||
using std::abs;
|
||||
EIGEN_STATIC_ASSERT( Deg == Dynamic || 1 < Deg, YOU_MADE_A_PROGRAMMING_MISTAKE );
|
||||
const Index deg = m_monic.size();
|
||||
const Index deg_1 = deg-1;
|
||||
|
||||
@@ -69,10 +69,11 @@ class PolynomialSolverBase
|
||||
inline void realRoots( Stl_back_insertion_sequence& bi_seq,
|
||||
const RealScalar& absImaginaryThreshold = NumTraits<Scalar>::dummy_precision() ) const
|
||||
{
|
||||
using std::abs;
|
||||
bi_seq.clear();
|
||||
for(Index i=0; i<m_roots.size(); ++i )
|
||||
{
|
||||
if( internal::abs( m_roots[i].imag() ) < absImaginaryThreshold ){
|
||||
if( abs( m_roots[i].imag() ) < absImaginaryThreshold ){
|
||||
bi_seq.push_back( m_roots[i].real() ); }
|
||||
}
|
||||
}
|
||||
@@ -118,13 +119,14 @@ class PolynomialSolverBase
|
||||
bool& hasArealRoot,
|
||||
const RealScalar& absImaginaryThreshold = NumTraits<Scalar>::dummy_precision() ) const
|
||||
{
|
||||
using std::abs;
|
||||
hasArealRoot = false;
|
||||
Index res=0;
|
||||
RealScalar abs2(0);
|
||||
|
||||
for( Index i=0; i<m_roots.size(); ++i )
|
||||
{
|
||||
if( internal::abs( m_roots[i].imag() ) < absImaginaryThreshold )
|
||||
if( abs( m_roots[i].imag() ) < absImaginaryThreshold )
|
||||
{
|
||||
if( !hasArealRoot )
|
||||
{
|
||||
@@ -144,7 +146,7 @@ class PolynomialSolverBase
|
||||
}
|
||||
else
|
||||
{
|
||||
if( internal::abs( m_roots[i].imag() ) < internal::abs( m_roots[res].imag() ) ){
|
||||
if( abs( m_roots[i].imag() ) < abs( m_roots[res].imag() ) ){
|
||||
res = i; }
|
||||
}
|
||||
}
|
||||
@@ -158,13 +160,14 @@ class PolynomialSolverBase
|
||||
bool& hasArealRoot,
|
||||
const RealScalar& absImaginaryThreshold = NumTraits<Scalar>::dummy_precision() ) const
|
||||
{
|
||||
using std::abs;
|
||||
hasArealRoot = false;
|
||||
Index res=0;
|
||||
RealScalar val(0);
|
||||
|
||||
for( Index i=0; i<m_roots.size(); ++i )
|
||||
{
|
||||
if( internal::abs( m_roots[i].imag() ) < absImaginaryThreshold )
|
||||
if( abs( m_roots[i].imag() ) < absImaginaryThreshold )
|
||||
{
|
||||
if( !hasArealRoot )
|
||||
{
|
||||
@@ -184,7 +187,7 @@ class PolynomialSolverBase
|
||||
}
|
||||
else
|
||||
{
|
||||
if( internal::abs( m_roots[i].imag() ) < internal::abs( m_roots[res].imag() ) ){
|
||||
if( abs( m_roots[i].imag() ) < abs( m_roots[res].imag() ) ){
|
||||
res = i; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ template <typename Polynomial>
|
||||
inline
|
||||
typename NumTraits<typename Polynomial::Scalar>::Real cauchy_max_bound( const Polynomial& poly )
|
||||
{
|
||||
using std::abs;
|
||||
typedef typename Polynomial::Scalar Scalar;
|
||||
typedef typename NumTraits<Scalar>::Real Real;
|
||||
|
||||
@@ -82,7 +83,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 += internal::abs(poly[i]*inv_leading_coeff); }
|
||||
cb += abs(poly[i]*inv_leading_coeff); }
|
||||
return cb + Real(1);
|
||||
}
|
||||
|
||||
@@ -96,6 +97,7 @@ template <typename Polynomial>
|
||||
inline
|
||||
typename NumTraits<typename Polynomial::Scalar>::Real cauchy_min_bound( const Polynomial& poly )
|
||||
{
|
||||
using std::abs;
|
||||
typedef typename Polynomial::Scalar Scalar;
|
||||
typedef typename NumTraits<Scalar>::Real Real;
|
||||
|
||||
@@ -107,7 +109,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 += internal::abs(poly[j]*inv_min_coeff); }
|
||||
cb += abs(poly[j]*inv_min_coeff); }
|
||||
return Real(1)/cb;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,5 +49,5 @@ int main()
|
||||
cout.precision(10);
|
||||
cout << "The last root in float then in double: " << psolvef.roots()[5] << "\t" << psolve6d.roots()[5] << endl;
|
||||
std::complex<float> castedRoot( psolve6d.roots()[5].real(), psolve6d.roots()[5].imag() );
|
||||
cout << "Norm of the difference: " << internal::abs( psolvef.roots()[5] - castedRoot ) << endl;
|
||||
cout << "Norm of the difference: " << std::abs( psolvef.roots()[5] - castedRoot ) << endl;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
// It is intended to be done for this test only.
|
||||
#include <Eigen/src/Core/util/DisableStupidWarnings.h>
|
||||
|
||||
using std::sqrt;
|
||||
|
||||
int fcn_chkder(const VectorXd &x, VectorXd &fvec, MatrixXd &fjac, int iflag)
|
||||
{
|
||||
/* subroutine fcn for chkder example. */
|
||||
@@ -795,7 +797,9 @@ struct hahn1_functor : Functor<double>
|
||||
static const double m_x[236];
|
||||
int operator()(const VectorXd &b, VectorXd &fvec)
|
||||
{
|
||||
static const double m_y[236] = { .591E0 , 1.547E0 , 2.902E0 , 2.894E0 , 4.703E0 , 6.307E0 , 7.03E0 , 7.898E0 , 9.470E0 , 9.484E0 , 10.072E0 , 10.163E0 , 11.615E0 , 12.005E0 , 12.478E0 , 12.982E0 , 12.970E0 , 13.926E0 , 14.452E0 , 14.404E0 , 15.190E0 , 15.550E0 , 15.528E0 , 15.499E0 , 16.131E0 , 16.438E0 , 16.387E0 , 16.549E0 , 16.872E0 , 16.830E0 , 16.926E0 , 16.907E0 , 16.966E0 , 17.060E0 , 17.122E0 , 17.311E0 , 17.355E0 , 17.668E0 , 17.767E0 , 17.803E0 , 17.765E0 , 17.768E0 , 17.736E0 , 17.858E0 , 17.877E0 , 17.912E0 , 18.046E0 , 18.085E0 , 18.291E0 , 18.357E0 , 18.426E0 , 18.584E0 , 18.610E0 , 18.870E0 , 18.795E0 , 19.111E0 , .367E0 , .796E0 , 0.892E0 , 1.903E0 , 2.150E0 , 3.697E0 , 5.870E0 , 6.421E0 , 7.422E0 , 9.944E0 , 11.023E0 , 11.87E0 , 12.786E0 , 14.067E0 , 13.974E0 , 14.462E0 , 14.464E0 , 15.381E0 , 15.483E0 , 15.59E0 , 16.075E0 , 16.347E0 , 16.181E0 , 16.915E0 , 17.003E0 , 16.978E0 , 17.756E0 , 17.808E0 , 17.868E0 , 18.481E0 , 18.486E0 , 19.090E0 , 16.062E0 , 16.337E0 , 16.345E0 , 16.388E0 , 17.159E0 , 17.116E0 , 17.164E0 , 17.123E0 , 17.979E0 , 17.974E0 , 18.007E0 , 17.993E0 , 18.523E0 , 18.669E0 , 18.617E0 , 19.371E0 , 19.330E0 , 0.080E0 , 0.248E0 , 1.089E0 , 1.418E0 , 2.278E0 , 3.624E0 , 4.574E0 , 5.556E0 , 7.267E0 , 7.695E0 , 9.136E0 , 9.959E0 , 9.957E0 , 11.600E0 , 13.138E0 , 13.564E0 , 13.871E0 , 13.994E0 , 14.947E0 , 15.473E0 , 15.379E0 , 15.455E0 , 15.908E0 , 16.114E0 , 17.071E0 , 17.135E0 , 17.282E0 , 17.368E0 , 17.483E0 , 17.764E0 , 18.185E0 , 18.271E0 , 18.236E0 , 18.237E0 , 18.523E0 , 18.627E0 , 18.665E0 , 19.086E0 , 0.214E0 , 0.943E0 , 1.429E0 , 2.241E0 , 2.951E0 , 3.782E0 , 4.757E0 , 5.602E0 , 7.169E0 , 8.920E0 , 10.055E0 , 12.035E0 , 12.861E0 , 13.436E0 , 14.167E0 , 14.755E0 , 15.168E0 , 15.651E0 , 15.746E0 , 16.216E0 , 16.445E0 , 16.965E0 , 17.121E0 , 17.206E0 , 17.250E0 , 17.339E0 , 17.793E0 , 18.123E0 , 18.49E0 , 18.566E0 , 18.645E0 , 18.706E0 , 18.924E0 , 19.1E0 , 0.375E0 , 0.471E0 , 1.504E0 , 2.204E0 , 2.813E0 , 4.765E0 , 9.835E0 , 10.040E0 , 11.946E0 , 12.596E0 , 13.303E0 , 13.922E0 , 14.440E0 , 14.951E0 , 15.627E0 , 15.639E0 , 15.814E0 , 16.315E0 , 16.334E0 , 16.430E0 , 16.423E0 , 17.024E0 , 17.009E0 , 17.165E0 , 17.134E0 , 17.349E0 , 17.576E0 , 17.848E0 , 18.090E0 , 18.276E0 , 18.404E0 , 18.519E0 , 19.133E0 , 19.074E0 , 19.239E0 , 19.280E0 , 19.101E0 , 19.398E0 , 19.252E0 , 19.89E0 , 20.007E0 , 19.929E0 , 19.268E0 , 19.324E0 , 20.049E0 , 20.107E0 , 20.062E0 , 20.065E0 , 19.286E0 , 19.972E0 , 20.088E0 , 20.743E0 , 20.83E0 , 20.935E0 , 21.035E0 , 20.93E0 , 21.074E0 , 21.085E0 , 20.935E0 };
|
||||
static const double m_y[236] = { .591E0 , 1.547E0 , 2.902E0 , 2.894E0 , 4.703E0 , 6.307E0 , 7.03E0 , 7.898E0 , 9.470E0 , 9.484E0 , 10.072E0 , 10.163E0 , 11.615E0 , 12.005E0 , 12.478E0 , 12.982E0 , 12.970E0 , 13.926E0 , 14.452E0 , 14.404E0 , 15.190E0 , 15.550E0 , 15.528E0 , 15.499E0 , 16.131E0 , 16.438E0 , 16.387E0 , 16.549E0 , 16.872E0 , 16.830E0 , 16.926E0 , 16.907E0 , 16.966E0 , 17.060E0 , 17.122E0 , 17.311E0 , 17.355E0 , 17.668E0 , 17.767E0 , 17.803E0 , 17.765E0 , 17.768E0 , 17.736E0 , 17.858E0 , 17.877E0 , 17.912E0 , 18.046E0 , 18.085E0 , 18.291E0 , 18.357E0 , 18.426E0 , 18.584E0 , 18.610E0 , 18.870E0 , 18.795E0 , 19.111E0 , .367E0 , .796E0 , 0.892E0 , 1.903E0 , 2.150E0 , 3.697E0 , 5.870E0 , 6.421E0 , 7.422E0 , 9.944E0 , 11.023E0 , 11.87E0 , 12.786E0 , 14.067E0 , 13.974E0 , 14.462E0 , 14.464E0 , 15.381E0 , 15.483E0 , 15.59E0 , 16.075E0 , 16.347E0 , 16.181E0 , 16.915E0 , 17.003E0 , 16.978E0 , 17.756E0 , 17.808E0 , 17.868E0 , 18.481E0 , 18.486E0 , 19.090E0 , 16.062E0 , 16.337E0 , 16.345E0 ,
|
||||
16.388E0 , 17.159E0 , 17.116E0 , 17.164E0 , 17.123E0 , 17.979E0 , 17.974E0 , 18.007E0 , 17.993E0 , 18.523E0 , 18.669E0 , 18.617E0 , 19.371E0 , 19.330E0 , 0.080E0 , 0.248E0 , 1.089E0 , 1.418E0 , 2.278E0 , 3.624E0 , 4.574E0 , 5.556E0 , 7.267E0 , 7.695E0 , 9.136E0 , 9.959E0 , 9.957E0 , 11.600E0 , 13.138E0 , 13.564E0 , 13.871E0 , 13.994E0 , 14.947E0 , 15.473E0 , 15.379E0 , 15.455E0 , 15.908E0 , 16.114E0 , 17.071E0 , 17.135E0 , 17.282E0 , 17.368E0 , 17.483E0 , 17.764E0 , 18.185E0 , 18.271E0 , 18.236E0 , 18.237E0 , 18.523E0 , 18.627E0 , 18.665E0 , 19.086E0 , 0.214E0 , 0.943E0 , 1.429E0 , 2.241E0 , 2.951E0 , 3.782E0 , 4.757E0 , 5.602E0 , 7.169E0 , 8.920E0 , 10.055E0 , 12.035E0 , 12.861E0 , 13.436E0 , 14.167E0 , 14.755E0 , 15.168E0 , 15.651E0 , 15.746E0 , 16.216E0 , 16.445E0 , 16.965E0 , 17.121E0 , 17.206E0 , 17.250E0 , 17.339E0 , 17.793E0 , 18.123E0 , 18.49E0 , 18.566E0 , 18.645E0 , 18.706E0 , 18.924E0 , 19.1E0 , 0.375E0 , 0.471E0 , 1.504E0 , 2.204E0 , 2.813E0 , 4.765E0 , 9.835E0 , 10.040E0 , 11.946E0 , 12.596E0 ,
|
||||
13.303E0 , 13.922E0 , 14.440E0 , 14.951E0 , 15.627E0 , 15.639E0 , 15.814E0 , 16.315E0 , 16.334E0 , 16.430E0 , 16.423E0 , 17.024E0 , 17.009E0 , 17.165E0 , 17.134E0 , 17.349E0 , 17.576E0 , 17.848E0 , 18.090E0 , 18.276E0 , 18.404E0 , 18.519E0 , 19.133E0 , 19.074E0 , 19.239E0 , 19.280E0 , 19.101E0 , 19.398E0 , 19.252E0 , 19.89E0 , 20.007E0 , 19.929E0 , 19.268E0 , 19.324E0 , 20.049E0 , 20.107E0 , 20.062E0 , 20.065E0 , 19.286E0 , 19.972E0 , 20.088E0 , 20.743E0 , 20.83E0 , 20.935E0 , 21.035E0 , 20.93E0 , 21.074E0 , 21.085E0 , 20.935E0 };
|
||||
|
||||
// int called=0; printf("call hahn1_functor with iflag=%d, called=%d\n", iflag, called); if (iflag==1) called++;
|
||||
|
||||
@@ -828,7 +832,9 @@ struct hahn1_functor : Functor<double>
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
const double hahn1_functor::m_x[236] = { 24.41E0 , 34.82E0 , 44.09E0 , 45.07E0 , 54.98E0 , 65.51E0 , 70.53E0 , 75.70E0 , 89.57E0 , 91.14E0 , 96.40E0 , 97.19E0 , 114.26E0 , 120.25E0 , 127.08E0 , 133.55E0 , 133.61E0 , 158.67E0 , 172.74E0 , 171.31E0 , 202.14E0 , 220.55E0 , 221.05E0 , 221.39E0 , 250.99E0 , 268.99E0 , 271.80E0 , 271.97E0 , 321.31E0 , 321.69E0 , 330.14E0 , 333.03E0 , 333.47E0 , 340.77E0 , 345.65E0 , 373.11E0 , 373.79E0 , 411.82E0 , 419.51E0 , 421.59E0 , 422.02E0 , 422.47E0 , 422.61E0 , 441.75E0 , 447.41E0 , 448.7E0 , 472.89E0 , 476.69E0 , 522.47E0 , 522.62E0 , 524.43E0 , 546.75E0 , 549.53E0 , 575.29E0 , 576.00E0 , 625.55E0 , 20.15E0 , 28.78E0 , 29.57E0 , 37.41E0 , 39.12E0 , 50.24E0 , 61.38E0 , 66.25E0 , 73.42E0 , 95.52E0 , 107.32E0 , 122.04E0 , 134.03E0 , 163.19E0 , 163.48E0 , 175.70E0 , 179.86E0 , 211.27E0 , 217.78E0 , 219.14E0 , 262.52E0 , 268.01E0 , 268.62E0 , 336.25E0 , 337.23E0 , 339.33E0 , 427.38E0 , 428.58E0 , 432.68E0 , 528.99E0 , 531.08E0 , 628.34E0 , 253.24E0 , 273.13E0 , 273.66E0 , 282.10E0 , 346.62E0 , 347.19E0 , 348.78E0 , 351.18E0 , 450.10E0 , 450.35E0 , 451.92E0 , 455.56E0 , 552.22E0 , 553.56E0 , 555.74E0 , 652.59E0 , 656.20E0 , 14.13E0 , 20.41E0 , 31.30E0 , 33.84E0 , 39.70E0 , 48.83E0 , 54.50E0 , 60.41E0 , 72.77E0 , 75.25E0 , 86.84E0 , 94.88E0 , 96.40E0 , 117.37E0 , 139.08E0 , 147.73E0 , 158.63E0 , 161.84E0 , 192.11E0 , 206.76E0 , 209.07E0 , 213.32E0 , 226.44E0 , 237.12E0 , 330.90E0 , 358.72E0 , 370.77E0 , 372.72E0 , 396.24E0 , 416.59E0 , 484.02E0 , 495.47E0 , 514.78E0 , 515.65E0 , 519.47E0 , 544.47E0 , 560.11E0 , 620.77E0 , 18.97E0 , 28.93E0 , 33.91E0 , 40.03E0 , 44.66E0 , 49.87E0 , 55.16E0 , 60.90E0 , 72.08E0 , 85.15E0 , 97.06E0 , 119.63E0 , 133.27E0 , 143.84E0 , 161.91E0 , 180.67E0 , 198.44E0 , 226.86E0 , 229.65E0 , 258.27E0 , 273.77E0 , 339.15E0 , 350.13E0 , 362.75E0 , 371.03E0 , 393.32E0 , 448.53E0 , 473.78E0 , 511.12E0 , 524.70E0 , 548.75E0 , 551.64E0 , 574.02E0 , 623.86E0 , 21.46E0 , 24.33E0 , 33.43E0 , 39.22E0 , 44.18E0 , 55.02E0 , 94.33E0 , 96.44E0 , 118.82E0 , 128.48E0 , 141.94E0 , 156.92E0 , 171.65E0 , 190.00E0 , 223.26E0 , 223.88E0 , 231.50E0 , 265.05E0 , 269.44E0 , 271.78E0 , 273.46E0 , 334.61E0 , 339.79E0 , 349.52E0 , 358.18E0 , 377.98E0 , 394.77E0 , 429.66E0 , 468.22E0 , 487.27E0 , 519.54E0 , 523.03E0 , 612.99E0 , 638.59E0 , 641.36E0 , 622.05E0 , 631.50E0 , 663.97E0 , 646.9E0 , 748.29E0 , 749.21E0 , 750.14E0 , 647.04E0 , 646.89E0 , 746.9E0 , 748.43E0 , 747.35E0 , 749.27E0 , 647.61E0 , 747.78E0 , 750.51E0 , 851.37E0 , 845.97E0 , 847.54E0 , 849.93E0 , 851.61E0 , 849.75E0 , 850.98E0 , 848.23E0};
|
||||
const double hahn1_functor::m_x[236] = { 24.41E0 , 34.82E0 , 44.09E0 , 45.07E0 , 54.98E0 , 65.51E0 , 70.53E0 , 75.70E0 , 89.57E0 , 91.14E0 , 96.40E0 , 97.19E0 , 114.26E0 , 120.25E0 , 127.08E0 , 133.55E0 , 133.61E0 , 158.67E0 , 172.74E0 , 171.31E0 , 202.14E0 , 220.55E0 , 221.05E0 , 221.39E0 , 250.99E0 , 268.99E0 , 271.80E0 , 271.97E0 , 321.31E0 , 321.69E0 , 330.14E0 , 333.03E0 , 333.47E0 , 340.77E0 , 345.65E0 , 373.11E0 , 373.79E0 , 411.82E0 , 419.51E0 , 421.59E0 , 422.02E0 , 422.47E0 , 422.61E0 , 441.75E0 , 447.41E0 , 448.7E0 , 472.89E0 , 476.69E0 , 522.47E0 , 522.62E0 , 524.43E0 , 546.75E0 , 549.53E0 , 575.29E0 , 576.00E0 , 625.55E0 , 20.15E0 , 28.78E0 , 29.57E0 , 37.41E0 , 39.12E0 , 50.24E0 , 61.38E0 , 66.25E0 , 73.42E0 , 95.52E0 , 107.32E0 , 122.04E0 , 134.03E0 , 163.19E0 , 163.48E0 , 175.70E0 , 179.86E0 , 211.27E0 , 217.78E0 , 219.14E0 , 262.52E0 , 268.01E0 , 268.62E0 , 336.25E0 , 337.23E0 , 339.33E0 , 427.38E0 , 428.58E0 , 432.68E0 , 528.99E0 , 531.08E0 , 628.34E0 , 253.24E0 , 273.13E0 , 273.66E0 ,
|
||||
282.10E0 , 346.62E0 , 347.19E0 , 348.78E0 , 351.18E0 , 450.10E0 , 450.35E0 , 451.92E0 , 455.56E0 , 552.22E0 , 553.56E0 , 555.74E0 , 652.59E0 , 656.20E0 , 14.13E0 , 20.41E0 , 31.30E0 , 33.84E0 , 39.70E0 , 48.83E0 , 54.50E0 , 60.41E0 , 72.77E0 , 75.25E0 , 86.84E0 , 94.88E0 , 96.40E0 , 117.37E0 , 139.08E0 , 147.73E0 , 158.63E0 , 161.84E0 , 192.11E0 , 206.76E0 , 209.07E0 , 213.32E0 , 226.44E0 , 237.12E0 , 330.90E0 , 358.72E0 , 370.77E0 , 372.72E0 , 396.24E0 , 416.59E0 , 484.02E0 , 495.47E0 , 514.78E0 , 515.65E0 , 519.47E0 , 544.47E0 , 560.11E0 , 620.77E0 , 18.97E0 , 28.93E0 , 33.91E0 , 40.03E0 , 44.66E0 , 49.87E0 , 55.16E0 , 60.90E0 , 72.08E0 , 85.15E0 , 97.06E0 , 119.63E0 , 133.27E0 , 143.84E0 , 161.91E0 , 180.67E0 , 198.44E0 , 226.86E0 , 229.65E0 , 258.27E0 , 273.77E0 , 339.15E0 , 350.13E0 , 362.75E0 , 371.03E0 , 393.32E0 , 448.53E0 , 473.78E0 , 511.12E0 , 524.70E0 , 548.75E0 , 551.64E0 , 574.02E0 , 623.86E0 , 21.46E0 , 24.33E0 , 33.43E0 , 39.22E0 , 44.18E0 , 55.02E0 , 94.33E0 , 96.44E0 , 118.82E0 , 128.48E0 ,
|
||||
141.94E0 , 156.92E0 , 171.65E0 , 190.00E0 , 223.26E0 , 223.88E0 , 231.50E0 , 265.05E0 , 269.44E0 , 271.78E0 , 273.46E0 , 334.61E0 , 339.79E0 , 349.52E0 , 358.18E0 , 377.98E0 , 394.77E0 , 429.66E0 , 468.22E0 , 487.27E0 , 519.54E0 , 523.03E0 , 612.99E0 , 638.59E0 , 641.36E0 , 622.05E0 , 631.50E0 , 663.97E0 , 646.9E0 , 748.29E0 , 749.21E0 , 750.14E0 , 647.04E0 , 646.89E0 , 746.9E0 , 748.43E0 , 747.35E0 , 749.27E0 , 647.61E0 , 747.78E0 , 750.51E0 , 851.37E0 , 845.97E0 , 847.54E0 , 849.93E0 , 851.61E0 , 849.75E0 , 850.98E0 , 848.23E0};
|
||||
|
||||
// http://www.itl.nist.gov/div898/strd/nls/data/hahn1.shtml
|
||||
void testNistHahn1(void)
|
||||
@@ -1485,8 +1491,11 @@ struct Bennett5_functor : Functor<double>
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
const double Bennett5_functor::x[154] = { 7.447168E0, 8.102586E0, 8.452547E0, 8.711278E0, 8.916774E0, 9.087155E0, 9.232590E0, 9.359535E0, 9.472166E0, 9.573384E0, 9.665293E0, 9.749461E0, 9.827092E0, 9.899128E0, 9.966321E0, 10.029280E0, 10.088510E0, 10.144430E0, 10.197380E0, 10.247670E0, 10.295560E0, 10.341250E0, 10.384950E0, 10.426820E0, 10.467000E0, 10.505640E0, 10.542830E0, 10.578690E0, 10.613310E0, 10.646780E0, 10.679150E0, 10.710520E0, 10.740920E0, 10.770440E0, 10.799100E0, 10.826970E0, 10.854080E0, 10.880470E0, 10.906190E0, 10.931260E0, 10.955720E0, 10.979590E0, 11.002910E0, 11.025700E0, 11.047980E0, 11.069770E0, 11.091100E0, 11.111980E0, 11.132440E0, 11.152480E0, 11.172130E0, 11.191410E0, 11.210310E0, 11.228870E0, 11.247090E0, 11.264980E0, 11.282560E0, 11.299840E0, 11.316820E0, 11.333520E0, 11.349940E0, 11.366100E0, 11.382000E0, 11.397660E0, 11.413070E0, 11.428240E0, 11.443200E0, 11.457930E0, 11.472440E0, 11.486750E0, 11.500860E0, 11.514770E0, 11.528490E0, 11.542020E0, 11.555380E0, 11.568550E0, 11.581560E0, 11.594420E0, 11.607121E0, 11.619640E0, 11.632000E0, 11.644210E0, 11.656280E0, 11.668200E0, 11.679980E0, 11.691620E0, 11.703130E0, 11.714510E0, 11.725760E0, 11.736880E0, 11.747890E0, 11.758780E0, 11.769550E0, 11.780200E0, 11.790730E0, 11.801160E0, 11.811480E0, 11.821700E0, 11.831810E0, 11.841820E0, 11.851730E0, 11.861550E0, 11.871270E0, 11.880890E0, 11.890420E0, 11.899870E0, 11.909220E0, 11.918490E0, 11.927680E0, 11.936780E0, 11.945790E0, 11.954730E0, 11.963590E0, 11.972370E0, 11.981070E0, 11.989700E0, 11.998260E0, 12.006740E0, 12.015150E0, 12.023490E0, 12.031760E0, 12.039970E0, 12.048100E0, 12.056170E0, 12.064180E0, 12.072120E0, 12.080010E0, 12.087820E0, 12.095580E0, 12.103280E0, 12.110920E0, 12.118500E0, 12.126030E0, 12.133500E0, 12.140910E0, 12.148270E0, 12.155570E0, 12.162830E0, 12.170030E0, 12.177170E0, 12.184270E0, 12.191320E0, 12.198320E0, 12.205270E0, 12.212170E0, 12.219030E0, 12.225840E0, 12.232600E0, 12.239320E0, 12.245990E0, 12.252620E0, 12.259200E0, 12.265750E0, 12.272240E0 };
|
||||
const double Bennett5_functor::y[154] = { -34.834702E0 ,-34.393200E0 ,-34.152901E0 ,-33.979099E0 ,-33.845901E0 ,-33.732899E0 ,-33.640301E0 ,-33.559200E0 ,-33.486801E0 ,-33.423100E0 ,-33.365101E0 ,-33.313000E0 ,-33.260899E0 ,-33.217400E0 ,-33.176899E0 ,-33.139198E0 ,-33.101601E0 ,-33.066799E0 ,-33.035000E0 ,-33.003101E0 ,-32.971298E0 ,-32.942299E0 ,-32.916302E0 ,-32.890202E0 ,-32.864101E0 ,-32.841000E0 ,-32.817799E0 ,-32.797501E0 ,-32.774300E0 ,-32.757000E0 ,-32.733799E0 ,-32.716400E0 ,-32.699100E0 ,-32.678799E0 ,-32.661400E0 ,-32.644001E0 ,-32.626701E0 ,-32.612202E0 ,-32.597698E0 ,-32.583199E0 ,-32.568699E0 ,-32.554298E0 ,-32.539799E0 ,-32.525299E0 ,-32.510799E0 ,-32.499199E0 ,-32.487598E0 ,-32.473202E0 ,-32.461601E0 ,-32.435501E0 ,-32.435501E0 ,-32.426800E0 ,-32.412300E0 ,-32.400799E0 ,-32.392101E0 ,-32.380501E0 ,-32.366001E0 ,-32.357300E0 ,-32.348598E0 ,-32.339901E0 ,-32.328400E0 ,-32.319698E0 ,-32.311001E0 ,-32.299400E0 ,-32.290699E0 ,-32.282001E0 ,-32.273300E0 ,-32.264599E0 ,-32.256001E0 ,-32.247299E0 ,-32.238602E0 ,-32.229900E0 ,-32.224098E0 ,-32.215401E0 ,-32.203800E0 ,-32.198002E0 ,-32.189400E0 ,-32.183601E0 ,-32.174900E0 ,-32.169102E0 ,-32.163300E0 ,-32.154598E0 ,-32.145901E0 ,-32.140099E0 ,-32.131401E0 ,-32.125599E0 ,-32.119801E0 ,-32.111198E0 ,-32.105400E0 ,-32.096699E0 ,-32.090900E0 ,-32.088001E0 ,-32.079300E0 ,-32.073502E0 ,-32.067699E0 ,-32.061901E0 ,-32.056099E0 ,-32.050301E0 ,-32.044498E0 ,-32.038799E0 ,-32.033001E0 ,-32.027199E0 ,-32.024300E0 ,-32.018501E0 ,-32.012699E0 ,-32.004002E0 ,-32.001099E0 ,-31.995300E0 ,-31.989500E0 ,-31.983700E0 ,-31.977900E0 ,-31.972099E0 ,-31.969299E0 ,-31.963501E0 ,-31.957701E0 ,-31.951900E0 ,-31.946100E0 ,-31.940300E0 ,-31.937401E0 ,-31.931601E0 ,-31.925800E0 ,-31.922899E0 ,-31.917101E0 ,-31.911301E0 ,-31.908400E0 ,-31.902599E0 ,-31.896900E0 ,-31.893999E0 ,-31.888201E0 ,-31.885300E0 ,-31.882401E0 ,-31.876600E0 ,-31.873699E0 ,-31.867901E0 ,-31.862101E0 ,-31.859200E0 ,-31.856300E0 ,-31.850500E0 ,-31.844700E0 ,-31.841801E0 ,-31.838900E0 ,-31.833099E0 ,-31.830200E0 ,-31.827299E0 ,-31.821600E0 ,-31.818701E0 ,-31.812901E0 ,-31.809999E0 ,-31.807100E0 ,-31.801300E0 ,-31.798401E0 ,-31.795500E0 ,-31.789700E0 ,-31.786800E0 };
|
||||
const double Bennett5_functor::x[154] = { 7.447168E0, 8.102586E0, 8.452547E0, 8.711278E0, 8.916774E0, 9.087155E0, 9.232590E0, 9.359535E0, 9.472166E0, 9.573384E0, 9.665293E0, 9.749461E0, 9.827092E0, 9.899128E0, 9.966321E0, 10.029280E0, 10.088510E0, 10.144430E0, 10.197380E0, 10.247670E0, 10.295560E0, 10.341250E0, 10.384950E0, 10.426820E0, 10.467000E0, 10.505640E0, 10.542830E0, 10.578690E0, 10.613310E0, 10.646780E0, 10.679150E0, 10.710520E0, 10.740920E0, 10.770440E0, 10.799100E0, 10.826970E0, 10.854080E0, 10.880470E0, 10.906190E0, 10.931260E0, 10.955720E0, 10.979590E0, 11.002910E0, 11.025700E0, 11.047980E0, 11.069770E0, 11.091100E0, 11.111980E0, 11.132440E0, 11.152480E0, 11.172130E0, 11.191410E0, 11.210310E0, 11.228870E0, 11.247090E0, 11.264980E0, 11.282560E0, 11.299840E0, 11.316820E0, 11.333520E0, 11.349940E0, 11.366100E0, 11.382000E0, 11.397660E0, 11.413070E0, 11.428240E0, 11.443200E0, 11.457930E0, 11.472440E0, 11.486750E0, 11.500860E0, 11.514770E0, 11.528490E0, 11.542020E0, 11.555380E0, 11.568550E0,
|
||||
11.581560E0, 11.594420E0, 11.607121E0, 11.619640E0, 11.632000E0, 11.644210E0, 11.656280E0, 11.668200E0, 11.679980E0, 11.691620E0, 11.703130E0, 11.714510E0, 11.725760E0, 11.736880E0, 11.747890E0, 11.758780E0, 11.769550E0, 11.780200E0, 11.790730E0, 11.801160E0, 11.811480E0, 11.821700E0, 11.831810E0, 11.841820E0, 11.851730E0, 11.861550E0, 11.871270E0, 11.880890E0, 11.890420E0, 11.899870E0, 11.909220E0, 11.918490E0, 11.927680E0, 11.936780E0, 11.945790E0, 11.954730E0, 11.963590E0, 11.972370E0, 11.981070E0, 11.989700E0, 11.998260E0, 12.006740E0, 12.015150E0, 12.023490E0, 12.031760E0, 12.039970E0, 12.048100E0, 12.056170E0, 12.064180E0, 12.072120E0, 12.080010E0, 12.087820E0, 12.095580E0, 12.103280E0, 12.110920E0, 12.118500E0, 12.126030E0, 12.133500E0, 12.140910E0, 12.148270E0, 12.155570E0, 12.162830E0, 12.170030E0, 12.177170E0, 12.184270E0, 12.191320E0, 12.198320E0, 12.205270E0, 12.212170E0, 12.219030E0, 12.225840E0, 12.232600E0, 12.239320E0, 12.245990E0, 12.252620E0, 12.259200E0, 12.265750E0, 12.272240E0 };
|
||||
const double Bennett5_functor::y[154] = { -34.834702E0 ,-34.393200E0 ,-34.152901E0 ,-33.979099E0 ,-33.845901E0 ,-33.732899E0 ,-33.640301E0 ,-33.559200E0 ,-33.486801E0 ,-33.423100E0 ,-33.365101E0 ,-33.313000E0 ,-33.260899E0 ,-33.217400E0 ,-33.176899E0 ,-33.139198E0 ,-33.101601E0 ,-33.066799E0 ,-33.035000E0 ,-33.003101E0 ,-32.971298E0 ,-32.942299E0 ,-32.916302E0 ,-32.890202E0 ,-32.864101E0 ,-32.841000E0 ,-32.817799E0 ,-32.797501E0 ,-32.774300E0 ,-32.757000E0 ,-32.733799E0 ,-32.716400E0 ,-32.699100E0 ,-32.678799E0 ,-32.661400E0 ,-32.644001E0 ,-32.626701E0 ,-32.612202E0 ,-32.597698E0 ,-32.583199E0 ,-32.568699E0 ,-32.554298E0 ,-32.539799E0 ,-32.525299E0 ,-32.510799E0 ,-32.499199E0 ,-32.487598E0 ,-32.473202E0 ,-32.461601E0 ,-32.435501E0 ,-32.435501E0 ,-32.426800E0 ,-32.412300E0 ,-32.400799E0 ,-32.392101E0 ,-32.380501E0 ,-32.366001E0 ,-32.357300E0 ,-32.348598E0 ,-32.339901E0 ,-32.328400E0 ,-32.319698E0 ,-32.311001E0 ,-32.299400E0 ,-32.290699E0 ,-32.282001E0 ,-32.273300E0 ,-32.264599E0 ,-32.256001E0 ,-32.247299E0
|
||||
,-32.238602E0 ,-32.229900E0 ,-32.224098E0 ,-32.215401E0 ,-32.203800E0 ,-32.198002E0 ,-32.189400E0 ,-32.183601E0 ,-32.174900E0 ,-32.169102E0 ,-32.163300E0 ,-32.154598E0 ,-32.145901E0 ,-32.140099E0 ,-32.131401E0 ,-32.125599E0 ,-32.119801E0 ,-32.111198E0 ,-32.105400E0 ,-32.096699E0 ,-32.090900E0 ,-32.088001E0 ,-32.079300E0 ,-32.073502E0 ,-32.067699E0 ,-32.061901E0 ,-32.056099E0 ,-32.050301E0 ,-32.044498E0 ,-32.038799E0 ,-32.033001E0 ,-32.027199E0 ,-32.024300E0 ,-32.018501E0 ,-32.012699E0 ,-32.004002E0 ,-32.001099E0 ,-31.995300E0 ,-31.989500E0 ,-31.983700E0 ,-31.977900E0 ,-31.972099E0 ,-31.969299E0 ,-31.963501E0 ,-31.957701E0 ,-31.951900E0 ,-31.946100E0 ,-31.940300E0 ,-31.937401E0 ,-31.931601E0 ,-31.925800E0 ,-31.922899E0 ,-31.917101E0 ,-31.911301E0 ,-31.908400E0 ,-31.902599E0 ,-31.896900E0 ,-31.893999E0 ,-31.888201E0 ,-31.885300E0 ,-31.882401E0 ,-31.876600E0 ,-31.873699E0 ,-31.867901E0 ,-31.862101E0 ,-31.859200E0 ,-31.856300E0 ,-31.850500E0 ,-31.844700E0 ,-31.841801E0 ,-31.838900E0 ,-31.833099E0 ,-31.830200E0 ,
|
||||
-31.827299E0 ,-31.821600E0 ,-31.818701E0 ,-31.812901E0 ,-31.809999E0 ,-31.807100E0 ,-31.801300E0 ,-31.798401E0 ,-31.795500E0 ,-31.789700E0 ,-31.786800E0 };
|
||||
|
||||
// http://www.itl.nist.gov/div898/strd/nls/data/bennett5.shtml
|
||||
void testNistBennett5(void)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla
|
||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include <cmath>
|
||||
|
||||
#include "../../test/sparse_solver.h"
|
||||
#include <Eigen/IterativeSolvers>
|
||||
|
||||
@@ -3194,7 +3194,7 @@ namespace std
|
||||
}
|
||||
}
|
||||
|
||||
inline static mpfr::mpreal min(mp_prec_t precision = mpfr::mpreal::get_default_prec())
|
||||
inline static mpfr::mpreal (min)(mp_prec_t precision = mpfr::mpreal::get_default_prec())
|
||||
{
|
||||
// min = 1/2*2^emin = 2^(emin-1)
|
||||
return mpfr::mpreal(1, precision) << mpfr::mpreal::get_emin()-1;
|
||||
@@ -3205,7 +3205,7 @@ namespace std
|
||||
return (-(max)(precision));
|
||||
}
|
||||
|
||||
inline static mpfr::mpreal max(mp_prec_t precision = mpfr::mpreal::get_default_prec())
|
||||
inline static mpfr::mpreal (max)(mp_prec_t precision = mpfr::mpreal::get_default_prec())
|
||||
{
|
||||
// max = (1-eps)*2^emax, eps is machine epsilon
|
||||
return (mpfr::mpreal(1, precision) - epsilon(precision)) << mpfr::mpreal::get_emax();
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <sstream>
|
||||
|
||||
using namespace mpfr;
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
|
||||
void test_mpreal_support()
|
||||
|
||||
@@ -92,6 +92,7 @@ void evalSolver( const POLYNOMIAL& pols )
|
||||
template< int Deg, typename POLYNOMIAL, typename ROOTS, typename REAL_ROOTS >
|
||||
void evalSolverSugarFunction( const POLYNOMIAL& pols, const ROOTS& roots, const REAL_ROOTS& real_roots )
|
||||
{
|
||||
using std::sqrt;
|
||||
typedef typename POLYNOMIAL::Scalar Scalar;
|
||||
|
||||
typedef PolynomialSolver<Scalar, Deg > PolynomialSolverType;
|
||||
@@ -115,7 +116,7 @@ void evalSolverSugarFunction( const POLYNOMIAL& pols, const ROOTS& roots, const
|
||||
psolve.realRoots( calc_realRoots );
|
||||
VERIFY( calc_realRoots.size() == (size_t)real_roots.size() );
|
||||
|
||||
const Scalar psPrec = internal::sqrt( test_precision<Scalar>() );
|
||||
const Scalar psPrec = sqrt( test_precision<Scalar>() );
|
||||
|
||||
for( size_t i=0; i<calc_realRoots.size(); ++i )
|
||||
{
|
||||
@@ -130,24 +131,24 @@ void evalSolverSugarFunction( const POLYNOMIAL& pols, const ROOTS& roots, const
|
||||
|
||||
//Test greatestRoot
|
||||
VERIFY( internal::isApprox( roots.array().abs().maxCoeff(),
|
||||
internal::abs( psolve.greatestRoot() ), psPrec ) );
|
||||
abs( psolve.greatestRoot() ), psPrec ) );
|
||||
|
||||
//Test smallestRoot
|
||||
VERIFY( internal::isApprox( roots.array().abs().minCoeff(),
|
||||
internal::abs( psolve.smallestRoot() ), psPrec ) );
|
||||
abs( psolve.smallestRoot() ), psPrec ) );
|
||||
|
||||
bool hasRealRoot;
|
||||
//Test absGreatestRealRoot
|
||||
Real r = psolve.absGreatestRealRoot( hasRealRoot );
|
||||
VERIFY( hasRealRoot == (real_roots.size() > 0 ) );
|
||||
if( hasRealRoot ){
|
||||
VERIFY( internal::isApprox( real_roots.array().abs().maxCoeff(), internal::abs(r), psPrec ) ); }
|
||||
VERIFY( internal::isApprox( real_roots.array().abs().maxCoeff(), abs(r), psPrec ) ); }
|
||||
|
||||
//Test absSmallestRealRoot
|
||||
r = psolve.absSmallestRealRoot( hasRealRoot );
|
||||
VERIFY( hasRealRoot == (real_roots.size() > 0 ) );
|
||||
if( hasRealRoot ){
|
||||
VERIFY( internal::isApprox( real_roots.array().abs().minCoeff(), internal::abs( r ), psPrec ) ); }
|
||||
VERIFY( internal::isApprox( real_roots.array().abs().minCoeff(), abs( r ), psPrec ) ); }
|
||||
|
||||
//Test greatestRealRoot
|
||||
r = psolve.greatestRealRoot( hasRealRoot );
|
||||
|
||||
Reference in New Issue
Block a user