From 54a0a9c9dd83aad42e79238ec8f0932b2a5e7881 Mon Sep 17 00:00:00 2001 From: Bernardo Bahia Monteiro Date: Sun, 29 Mar 2020 18:53:18 -0400 Subject: [PATCH] Bugfix: conjugate_gradient did not compile with lazy-evaluated RealScalar The error generated by the compiler was: no matching function for call to 'maxi' RealScalar threshold = numext::maxi(tol*tol*rhsNorm2,considerAsZero); The important part in the following notes was: candidate template ignored: deduced conflicting types for parameter 'T'" ('codi::Multiply11<...>' vs. 'codi::ActiveReal<...>') EIGEN_ALWAYS_INLINE T maxi(const T& x, const T& y) I am using CoDiPack to provide the RealScalar type. This bug was introduced in bc000deaa Fix conjugate-gradient for very small rhs --- Eigen/src/IterativeLinearSolvers/ConjugateGradient.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h b/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h index 96e8b9f8a..5d8c6b433 100644 --- a/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +++ b/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h @@ -51,7 +51,7 @@ void conjugate_gradient(const MatrixType& mat, const Rhs& rhs, Dest& x, return; } const RealScalar considerAsZero = (std::numeric_limits::min)(); - RealScalar threshold = numext::maxi(tol*tol*rhsNorm2,considerAsZero); + RealScalar threshold = numext::maxi(RealScalar(tol*tol*rhsNorm2),considerAsZero); RealScalar residualNorm2 = residual.squaredNorm(); if (residualNorm2 < threshold) {