New user self-registration is disabled due to spam. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Before reporting a bug, please make sure that your Eigen version is up-to-date!
Bug 636 - Eigen/src/Eigenvalues/EigenSolver.h should pass Scalar typename to cdiv explicitly
Summary: Eigen/src/Eigenvalues/EigenSolver.h should pass Scalar typename to cdiv expli...
Status: NEW
Alias: None
Product: Eigen
Classification: Unclassified
Component: Eigenvalues (show other bugs)
Version: unspecified
Hardware: All All
: Normal Unknown
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-29 05:58 UTC by Thad Hughes
Modified: 2013-07-29 06:08 UTC (History)
4 users (show)



Attachments

Description Thad Hughes 2013-07-29 05:58:16 UTC
For example, I think you should write this:

std::complex<Scalar> cc = cdiv<Scalar>(-ra,-sa,w,q);

Instead of this:

std::complex<Scalar> cc = cdiv(-ra,-sa,w,q);

There is one place in the file where it is done correctly, other places where it is not.

The reason is that if Scalar is a type that uses expression templates -ra is not necessarily the same type as w, so the type inference when invoking cdiv does not work correctly.
Comment 1 Thad Hughes 2013-07-29 06:08:21 UTC
To be clear, I'm suggesting this patch:

@@ -518,7 +518,7 @@ void EigenSolver<MatrixType>::doComputeEigenvectors()
           l = i;
           if (m_eivalues.coeff(i).imag() == RealScalar(0))
           {
-            std::complex<Scalar> cc = cdiv(-ra,-sa,w,q);
+            std::complex<Scalar> cc = cdiv<Scalar>(-ra,-sa,w,q);
             m_matT.coeffRef(i,n-1) = internal::real(cc);
             m_matT.coeffRef(i,n) = internal::imag(cc);
           }
@@ -532,7 +532,7 @@ void EigenSolver<MatrixType>::doComputeEigenvectors()
             if ((vr == 0.0) && (vi == 0.0))
               vr = eps * norm * (internal::abs(w) + internal::abs(q) + internal::abs(x) + internal::abs(y) + internal::abs(lastw));
 
-	    std::complex<Scalar> cc = cdiv(x*lastra-lastw*ra+q*sa,x*lastsa-lastw*sa-q*ra,vr,vi);
+	    std::complex<Scalar> cc = cdiv<Scalar>(x*lastra-lastw*ra+q*sa,x*lastsa-lastw*sa-q*ra,vr,vi);
             m_matT.coeffRef(i,n-1) = internal::real(cc);
             m_matT.coeffRef(i,n) = internal::imag(cc);
             if (internal::abs(x) > (internal::abs(lastw) + internal::abs(q)))
@@ -542,7 +542,7 @@ void EigenSolver<MatrixType>::doComputeEigenvectors()
             }
             else
             {
-              cc = cdiv(-lastra-y*m_matT.coeff(i,n-1),-lastsa-y*m_matT.coeff(i,n),lastw,q);
+              cc = cdiv<Scalar>(-lastra-y*m_matT.coeff(i,n-1),-lastsa-y*m_matT.coeff(i,n),lastw,q);
               m_matT.coeffRef(i+1,n-1) = internal::real(cc);
               m_matT.coeffRef(i+1,n) = internal::imag(cc);
             }

Note You need to log in before you can comment on or make changes to this bug.