Registered Member
|
Dear Eigen Users
I would like to implement a constitutive matrix occurring in plane stress conditions. I want this matrix to behave basically as a Eigen::Vector3d, except for the * operator, which I have overloaded in the following fashion:
I realize this implementation breaks Eigen’s lazy evaluation and vectorization, yet it works as I wanted. It is worth to implement a operator:
or whathever? Could somebody please provide advice on how to implement it? Thanks so much |
Moderator
|
For small objects, it is perfectly fine to return by values. Since the values will stay in register, the compiler will easily optimize all temporaries away. An index-based lazy evaluator will even be slower because of the complex management of the shuffled indices.
|
Moderator
|
BTW, be careful with such an implementation, because the following won't work as expected:
TVector3 a, b; (a+a)*(b+b) will call MatrixBase::operator*, not TVector3::operator*. In this case you'll get a compiler error because this matrix product is invalid, and since there is not matrix product taking 2 vectors and returning one vector, you should always get a compilation error in case of miss-use, but still, be aware of this possible loophole. |
Registered Member
|
Yes. This confused me. I thought:
was going to fail because the result of epsT+epsV would have not been implicitly promoted to TVect3D, and thus calling the "incorrect" operator * and, consequently, get an assertion failed of incompatible matrix sizes. However, it seem to work fine, at least with VC2015 Update 2. I'll try later with gcc and clang and post the result if relevant. BTW, thanks for your prompt response. |
Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient