If, for example, you change the line that says ADMatrix A_inv = A_.inverse();
to ADMatrix U = A_.jacobiSvd(Eigen::ComputeFullU).matrixU();
(and change A_inv
to U
four lines down) you get calls to sqrt
and hence a compiler error:
In file included from /home/ben/r-devel/library/StanHeaders/include/stan/math.hpp:4:
In file included from /home/ben/r-devel/library/StanHeaders/include/stan/math/rev/mat.hpp:11:
In file included from /home/ben/r-devel/library/StanHeaders/include/stan/math/rev/mat/vectorize/apply_scalar_unary.hpp:4:
/home/ben/r-devel/library/StanHeaders/include/stan/math/prim/mat/vectorize/apply_scalar_unary.hpp:39:37: error: implicit instantiation of undefined template
'Eigen::internal::traits<Eigen::AutoDiffScalar<Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<stan::math::var, stan::math::var>, const Eigen::Matrix<stan::math::var, -1, 1, 0,
-1, 1>, const Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> > > >'
typedef typename Eigen::internal::traits<T>::Scalar scalar_t;
^
/home/ben/r-devel/library/StanHeaders/include/stan/math/prim/mat/fun/sqrt.hpp:31:17: note: in instantiation of template class 'stan::math::apply_scalar_unary<stan::math::sqrt_fun,
Eigen::AutoDiffScalar<Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<stan::math::var, stan::math::var>, const Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1>, const
Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> > > >' requested here
inline typename apply_scalar_unary<sqrt_fun, T>::return_t sqrt(const T& x) {
^
/home/ben/r-devel/library/RcppEigen/include/Eigen/src/Householder/Householder.h:88:12: note: while substituting deduced template arguments into function template 'sqrt' [with T =
Eigen::AutoDiffScalar<Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<stan::math::var, stan::math::var>, const Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1>, const
Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> > >]
beta = sqrt(numext::abs2(c0) + tailSqNorm);
^
/home/ben/r-devel/library/RcppEigen/include/Eigen/src/Householder/Householder.h:45:3: note: in instantiation of function template specialization
'Eigen::MatrixBase<Eigen::Block<Eigen::Block<Eigen::Matrix<Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >, -1, -1, 0, -1, -1>, -1, 1, true>, -1, 1, false>
>::makeHouseholder<Eigen::VectorBlock<Eigen::Block<Eigen::Block<Eigen::Matrix<Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >, -1, -1, 0, -1, -1>, -1, 1,
true>, -1, 1, false>, -1> >' requested here
makeHouseholder(essentialPart, tau, beta);
^
/home/ben/r-devel/library/RcppEigen/include/Eigen/src/QR/ColPivHouseholderQR.h:538:30: note: in instantiation of member function
'Eigen::MatrixBase<Eigen::Block<Eigen::Block<Eigen::Matrix<Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >, -1, -1, 0, -1, -1>, -1, 1, true>, -1, 1, false>
>::makeHouseholderInPlace' requested here
m_qr.col(k).tail(rows-k).makeHouseholderInPlace(m_hCoeffs.coeffRef(k), beta);
^
/home/ben/r-devel/library/RcppEigen/include/Eigen/src/QR/ColPivHouseholderQR.h:475:3: note: in instantiation of member function
'Eigen::ColPivHouseholderQR<Eigen::Matrix<Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >, -1, -1, 0, -1, -1> >::computeInPlace' requested here
computeInPlace();
^
/home/ben/r-devel/library/RcppEigen/include/Eigen/src/SVD/JacobiSVD.h:230:12: note: in instantiation of function template specialization
'Eigen::ColPivHouseholderQR<Eigen::Matrix<Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >, -1, -1, 0, -1, -1>
>::compute<Eigen::Matrix<Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >, -1, -1, 0, -1, -1> >' requested here
m_qr.compute(m_adjoint);
^
/home/ben/r-devel/library/RcppEigen/include/Eigen/src/SVD/JacobiSVD.h:684:27: note: in instantiation of member function
'Eigen::internal::qr_preconditioner_impl<Eigen::Matrix<Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >, -1, -1, 0, -1, -1>, 2, 0, true>::run' requested here
m_qr_precond_morecols.run(*this, m_scaledMatrix);
^
/home/ben/r-devel/library/RcppEigen/include/Eigen/src/SVD/JacobiSVD.h:548:7: note: in instantiation of member function
'Eigen::JacobiSVD<Eigen::Matrix<Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >, -1, -1, 0, -1, -1>, 2>::compute' requested here
compute(matrix, computationOptions);
^
/home/ben/r-devel/library/RcppEigen/include/Eigen/src/SVD/JacobiSVD.h:799:10: note: in instantiation of member function
'Eigen::JacobiSVD<Eigen::Matrix<Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >, -1, -1, 0, -1, -1>, 2>::JacobiSVD' requested here
return JacobiSVD<PlainObject>(*this, computationOptions);
^
testJ2.cpp:26:19: note: in instantiation of member function 'Eigen::MatrixBase<Eigen::Matrix<Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >, -1, -1, 0, -1, -1>
>::jacobiSvd' requested here
ADMatrix U = A_.jacobiSvd(Eigen::ComputeFullU).matrixU();
^
/home/ben/r-devel/library/RcppEigen/include/Eigen/src/Core/util/ForwardDeclarations.h:17:29: note: template is declared here
template<typename T> struct traits;
^
In file included from testJ2.cpp:4:
In file included from /home/ben/r-devel/library/StanHeaders/include/stan/math.hpp:4:
In file included from /home/ben/r-devel/library/StanHeaders/include/stan/math/rev/mat.hpp:11:
In file included from /home/ben/r-devel/library/StanHeaders/include/stan/math/rev/mat/vectorize/apply_scalar_unary.hpp:4:
/home/ben/r-devel/library/StanHeaders/include/stan/math/prim/mat/vectorize/apply_scalar_unary.hpp:45:38: error: no member named 'RowsAtCompileTime' in
'Eigen::AutoDiffScalar<Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<stan::math::var, stan::math::var>, const Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1>, const
Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> > >'
typedef Eigen::Matrix<scalar_t, T::RowsAtCompileTime, T::ColsAtCompileTime>
~~~^
/home/ben/r-devel/library/StanHeaders/include/stan/math/prim/mat/vectorize/apply_scalar_unary.hpp:39:37: error: implicit instantiation of undefined template
'Eigen::internal::traits<Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> > >'
typedef typename Eigen::internal::traits<T>::Scalar scalar_t;
^
/home/ben/r-devel/library/StanHeaders/include/stan/math/prim/mat/fun/sqrt.hpp:31:17: note: in instantiation of template class 'stan::math::apply_scalar_unary<stan::math::sqrt_fun,
Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> > >' requested here
inline typename apply_scalar_unary<sqrt_fun, T>::return_t sqrt(const T& x) {
^
/home/ben/r-devel/library/RcppEigen/include/Eigen/src/Core/MathFunctions.h:1020:10: note: while substituting deduced template arguments into function template 'sqrt' [with T =
Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >]
return sqrt(x);
^
/home/ben/r-devel/library/RcppEigen/include/Eigen/src/QR/ColPivHouseholderQR.h:568:52: note: in instantiation of function template specialization
'Eigen::numext::sqrt<Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> > >' requested here
m_colNormsUpdated.coeffRef(j) *= numext::sqrt(temp);
^
/home/ben/r-devel/library/RcppEigen/include/Eigen/src/QR/ColPivHouseholderQR.h:475:3: note: in instantiation of member function
'Eigen::ColPivHouseholderQR<Eigen::Matrix<Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >, -1, -1, 0, -1, -1> >::computeInPlace' requested here
computeInPlace();
^
/home/ben/r-devel/library/RcppEigen/include/Eigen/src/SVD/JacobiSVD.h:230:12: note: in instantiation of function template specialization
'Eigen::ColPivHouseholderQR<Eigen::Matrix<Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >, -1, -1, 0, -1, -1>
>::compute<Eigen::Matrix<Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >, -1, -1, 0, -1, -1> >' requested here
m_qr.compute(m_adjoint);
^
/home/ben/r-devel/library/RcppEigen/include/Eigen/src/SVD/JacobiSVD.h:684:27: note: in instantiation of member function
'Eigen::internal::qr_preconditioner_impl<Eigen::Matrix<Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >, -1, -1, 0, -1, -1>, 2, 0, true>::run' requested here
m_qr_precond_morecols.run(*this, m_scaledMatrix);
^
/home/ben/r-devel/library/RcppEigen/include/Eigen/src/SVD/JacobiSVD.h:548:7: note: in instantiation of member function
'Eigen::JacobiSVD<Eigen::Matrix<Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >, -1, -1, 0, -1, -1>, 2>::compute' requested here
compute(matrix, computationOptions);
^
/home/ben/r-devel/library/RcppEigen/include/Eigen/src/SVD/JacobiSVD.h:799:10: note: in instantiation of member function
'Eigen::JacobiSVD<Eigen::Matrix<Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >, -1, -1, 0, -1, -1>, 2>::JacobiSVD' requested here
return JacobiSVD<PlainObject>(*this, computationOptions);
^
testJ2.cpp:26:19: note: in instantiation of member function 'Eigen::MatrixBase<Eigen::Matrix<Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >, -1, -1, 0, -1, -1>
>::jacobiSvd' requested here
ADMatrix U = A_.jacobiSvd(Eigen::ComputeFullU).matrixU();
^
/home/ben/r-devel/library/RcppEigen/include/Eigen/src/Core/util/ForwardDeclarations.h:17:29: note: template is declared here
template<typename T> struct traits;
^
In file included from testJ2.cpp:4:
In file included from /home/ben/r-devel/library/StanHeaders/include/stan/math.hpp:4:
In file included from /home/ben/r-devel/library/StanHeaders/include/stan/math/rev/mat.hpp:11:
In file included from /home/ben/r-devel/library/StanHeaders/include/stan/math/rev/mat/vectorize/apply_scalar_unary.hpp:4:
/home/ben/r-devel/library/StanHeaders/include/stan/math/prim/mat/vectorize/apply_scalar_unary.hpp:45:38: error: no member named 'RowsAtCompileTime' in
'Eigen::AutoDiffScalar<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >'
typedef Eigen::Matrix<scalar_t, T::RowsAtCompileTime, T::ColsAtCompileTime>
~~~^
1 warning and 4 errors generated.