<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div class="">I posted this same question on the Eigen forum because I do not know if it is really an Eigen issue or a CppAD issue.</div>
<div class=""><br class="">
</div>
<div class="">As part of a larger application that uses CppAD, I am trying to fill an Eigen sparse matrix. &nbsp;The following MWE does not use CppAD, and when the first line (#define EIGEN_MATRIX_PLUGIN ... ) is commented out, this code runs fine. &nbsp;</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<div class="">#define EIGEN_MATRIX_PLUGIN &lt;cppad/example/eigen_plugin.hpp&gt;</div>
<div class=""><br class="">
</div>
<div class="">#include &lt;Eigen/Eigen&gt;</div>
<div class="">#include &lt;Eigen/Sparse&gt;</div>
<div class="">#include &lt;cppad/cppad.hpp&gt;</div>
<div class="">#include &lt;cppad/example/cppad_eigen.hpp&gt;</div>
<div class=""><br class="">
</div>
<div class="">void triptest () {</div>
<div class="">&nbsp; typedef Eigen::Triplet&lt;double&gt; TT;</div>
<div class=""><br class="">
</div>
<div class="">&nbsp; int n = 5;</div>
<div class="">&nbsp; std::vector&lt;TT&gt; trips;&nbsp;</div>
<div class="">&nbsp; Eigen::SparseMatrix&lt;double&gt; M(n,n);</div>
<div class="">&nbsp;&nbsp;</div>
<div class="">&nbsp; for (int i=0; i&lt;n; i&#43;&#43;) { &nbsp;&nbsp;</div>
<div class="">&nbsp; &nbsp; trips.push_back (TT(i,i,i*i));</div>
<div class="">&nbsp; }</div>
<div class="">&nbsp; M.setFromTriplets(trips.begin(), trips.end());</div>
<div class="">&nbsp; std::cout &lt;&lt; M &lt;&lt; &quot;\n&quot;;</div>
<div class="">&nbsp;&nbsp;</div>
<div class="">}</div>
<div class=""><br class="">
</div>
<div class="">int main (void)</div>
<div class="">{ &nbsp;&nbsp;</div>
<div class="">&nbsp; triptest();</div>
<div class="">&nbsp; return 0;</div>
<div class="">}</div>
</div>
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">But when left in, I get the following compile error:</div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
&nbsp;$ clang&#43;&#43; -I/opt/cppad/include -I$R_HOME/library/RcppEigen/include trips.cpp -o trips.so</div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
In file included from trips.cpp:4:</div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
In file included from .../Eigen/Sparse:19:</div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
In file included from .../Eigen/SparseCore:40:</div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
<b class="">/Library/Frameworks/R.framework/Resources/library/RcppEigen/include/Eigen/src/SparseCore/SparseMatrix.h:957:11:
</b><span style="font-variant-ligatures: no-common-ligatures; color: #c1361e" class=""><b class="">error:&nbsp;</b></span></div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
<b class="">&nbsp; &nbsp; &nbsp; call to member function 'reserve' is ambiguous</b></div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
&nbsp; &nbsp; trMat.reserve(wi);</div>
<div style="margin: 0px; font-family: Menlo; color: rgb(49, 187, 36); background-color: rgb(255, 254, 237);" class="">
<b class="">&nbsp; &nbsp; ~~~~~~^~~~~~~</b></div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
<b class="">.../Eigen/src/SparseCore/SparseMatrix.h:1013:13: note:&nbsp;</b></div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
&nbsp; &nbsp; &nbsp; in instantiation of function template specialization</div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
&nbsp; &nbsp; &nbsp; 'Eigen::internal::set_from_triplets&lt;std::__1::__wrap_iter&lt;Eigen::Triplet&lt;double, int&gt; *&gt;,</div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
&nbsp; &nbsp; &nbsp; Eigen::SparseMatrix&lt;double, 0, int&gt; &gt;' requested here</div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
&nbsp; internal::set_from_triplets(begin, end, *this);</div>
<div style="margin: 0px; font-family: Menlo; color: rgb(49, 187, 36); background-color: rgb(255, 254, 237);" class="">
<b class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^</b></div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
<b class="">trips.cpp:18:5: note: </b>in instantiation of function template specialization 'Eigen::SparseMatrix&lt;double, 0,</div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
&nbsp; &nbsp; &nbsp; int&gt;::setFromTriplets&lt;std::__1::__wrap_iter&lt;Eigen::Triplet&lt;double, int&gt; *&gt; &gt;' requested here</div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
&nbsp; M.setFromTriplets(trips.begin(), trips.end());</div>
<div style="margin: 0px; font-family: Menlo; color: rgb(49, 187, 36); background-color: rgb(255, 254, 237);" class="">
<b class="">&nbsp; &nbsp; ^</b></div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
<b class="">.../Eigen/src/SparseCore/SparseMatrix.h:270:17: note:&nbsp;</b></div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
&nbsp; &nbsp; &nbsp; candidate function [with SizesType = Eigen::Matrix&lt;int, -1, 1, 0, -1, 1&gt;]</div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
&nbsp; &nbsp; inline void reserve(const SizesType&amp; reserveSizes, const typename SizesType::value_type&amp; enableif = typenam...</div>
<div style="margin: 0px; font-family: Menlo; color: rgb(49, 187, 36); background-color: rgb(255, 254, 237);" class="">
<b class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^</b></div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
<b class="">.../Eigen/src/SparseCore/SparseMatrix.h:276:17: note:&nbsp;</b></div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
&nbsp; &nbsp; &nbsp; candidate function [with SizesType = Eigen::Matrix&lt;int, -1, 1, 0, -1, 1&gt;]</div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
&nbsp; &nbsp; inline void reserve(const SizesType&amp; reserveSizes, const typename SizesType::Scalar&amp; enableif =</div>
<div style="margin: 0px; font-family: Menlo; color: rgb(49, 187, 36); background-color: rgb(255, 254, 237);" class="">
<b class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^</b></div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
<b class="">.../Eigen/src/SparseCore/SparseMatrix.h:256:17: note:&nbsp;</b></div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
&nbsp; &nbsp; &nbsp; candidate function not viable: no known conversion from 'Matrix&lt;Index, Dynamic, 1&gt;' to 'Index' (aka 'int') for 1st</div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
&nbsp; &nbsp; &nbsp; argument</div>
<div style="margin: 0px; font-family: Menlo; background-color: rgb(255, 254, 237);" class="">
&nbsp; &nbsp; inline void reserve(Index reserveSize)</div>
<div style="margin: 0px; font-family: Menlo; color: rgb(49, 187, 36); background-color: rgb(255, 254, 237);" class="">
<b class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^</b></div>
</div>
<div class=""><b class=""><br class="">
</b></div>
<div class=""><br class="">
</div>
<div class="">Any idea what's going on? &nbsp;I have been able to narrow the problem directly to that first #define. &nbsp;Also, this appears to happen only with EIGEN_MATRIX_PLUGIN, and not ARRAY or SPARSEMATRIX.</div>
<div class=""><br class="">
</div>
<div class="">Thanks,</div>
<div class=""><br class="">
</div>
<div class="">Michael</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<br class="">
<div apple-content-edited="true" class="">
<div class="">--------------------------</div>
<div class="">Michael Braun</div>
<div class="">Associate Professor of Marketing</div>
<div class="">Cox School of Business</div>
<div class="">Southern Methodist University</div>
<div class="">Dallas, TX 75275</div>
<div class=""><a href="mailto:braunm@smu.edu" class="">braunm@smu.edu</a></div>
<div class=""><br class="">
</div>
<br class="Apple-interchange-newline">
</div>
<br class="">
</body>
</html>