I'm trying to translate the following Matlab code to C/C++.
indl = find(dlamu1 < 0); indu = find(dlamu2 < 0);
s = min([1; -lamu1(indl)./dlamu1(indl); -lamu2(indu)./dlamu2(indu)]);
I've read on another thread that there's yet no equivalent in the Eigen library to the find()
function and I'm at peace with that and have brute-forced around it.
Now, if I wanted to do the coefficient-wise division of lamu1
and dlamu1
, I'd go for lamu1.cwiseQuotient(dlamu1)
but how do I go about doing that but only for some of their coefficients, which indexes are specified by the coefficients of indl
? I haven't found anything about this in the documentation, but maybe I'm not using the right search terms.
With the default branch you can just write lamu1(indl)
with indl
a std::vector<int>
or a Eigen::VectorXi
or whatever you like that supports random access through operator[]
.