-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Products of MatrixXd and MatrixXdual not working #73
Comments
Looks like something similar to this: where Eigen and CppAD are used together. I'll try to get this fixed soon (hopefully today, if the solution is there already! :)). Thanks for reporting, Alexander. |
Looks like this is a common (and non-resolved) issue when using custom types in Eigen. Here is another stackoverflow question (without a definite solution): Even adding the following piece of code in template<typename BinOp>
struct ScalarBinaryOpTraits<autodiff::dual, double, BinOp>
{
typedef autodiff::dual ReturnType;
};
template<typename BinOp>
struct ScalarBinaryOpTraits<double, autodiff::dual, BinOp>
{
typedef autodiff::dual ReturnType;
}; Would you please help me finding a solution for this, by possibly asking to Eigen developers? They most likely know how to resolve this. |
I also searched a bit and found Interestingly it also works for fixed sizes, e.g. Matrix3dual,Matrix3d. I'm reading right now through I'm confident to find a solution since a lot of people in the automatic diff community wasrequesting such a feature, e.g. Adol-C, CodiPack etc. |
I searched for several AD tools which also use eigen but i didn't fsomething useful in cppAD,adol-c, CodiPack, Stan math and https://gitlab.com/tesch1/cppduals/issues/3 has the same problem. Therefore i think casting is right know the only option. Since the Eigen people are aware of that problem and they fixed it in eigen 3.0 for Arrays i don't know how to think about this. Any thoughts about this? |
My opinion is that we keep this issue open and stay on top of the developments of Eigen in the direction of permitting the multiplication of matrices with different scalar types. Until then, I hope you can find an adequate temporary solution to your use case. ;) Let me know if you eventually find out something new about this. |
FYI, this also affects arbitrary operations when mixing Eigen types #include "Eigen/Core"
#include "autodiff/reverse.hpp"
#include "autodiff/reverse/eigen.hpp"
int main(void){
Eigen::VectorXvar Xv(10);
Eigen::VectorXd Y(10);
autodiff::var z = (Xv -Y).normSquared();
return 0;
} Would it be possible to make |
Hi @ludkinm - I'll check a fix for this. This should work for |
Thanks. I am using Eigen3.3.7 from the latest stable tarball and the master branch of autodiff if that helps. |
@allanleal, you nudge that |
Excellent you've found this. Yes, a PR would be great - thanks. |
In my code the products of type double and type dual inside Eigen Vectors and Matrices seems to be not working. Do i overlook something? My MWE looks like the following
which produces the following compilation error:
The text was updated successfully, but these errors were encountered: