Registered Member
|
I'm transferring some code I have from Python/numpy to C++/Eigen. One feature that's pretty handy in numpy is the argsort method, which returns a vector of the indices that would sort a sequence of numbers. The following code works, but since I'm not experienced with C++ or Eigen I'm sure it could be more efficient. The code below can take a row or column of a matrix and return a vector such that the asPermutation() method will provide a permutation that can be used to sort the matrix by the row or column. If anyone has a better way of doing this, I'd love to see it.
A few other questions: Is there any interest in some kind of wiki space where Eigen "recipes" could be shared? Coefficient-wise functions all appear to be methods in Eigen. Out of curiosity, why not just use functions that accept arrays as arguments (sin(a), cos(a), etc)? Would there be interest in creating a namespace of coefficient-wise functions that, in usage, would be more akin to Matlab/numpy/Fortran? Don't take my questions as complaints. Eigen is an amazing library, and once I get a bit more practice I'd love to contribute where I can.
/Edited because asPermutation() expects ( i -> x[i] ), whereas numpy expects (x[i] -> i) |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]