Be able to choose the order of eigenvalues
Currently the eigenvalue calculation returns the values in ascending order.
For several applications it is not uncommon to use them in descending order, which will require an additional operation to reverse the order.
If possible, I would like to request the possibility of selecting the order of the output.
Something like:
#include <iostream>
#include <vector>
#include <algorithm>
enum sortType{ascending, descending};
template<sortType S=ascending>
void sort (std::vector<double>& v)
{
std::sort(v.begin(), v.end());
}
template <>
void sort<descending> (std::vector<double>& v)
{
std::sort(v.begin(), v.end(), std::greater<>());
}
template<sortType S=ascending>
void foo(const std::vector<double>& v)
{
std::vector<double> v2 (v);
sort<S>(v2);
for (int i = 0; i< v.size(); i++)
{
std::cout << v2[i] << std::endl;
}
}
int main()
{
std::vector<double> tst = {1,3,4,2,5};
foo(tst);
foo<descending>(tst);
return 0;
}
This will keep the current code running as is, but with the flexibility of letting the user choose the order of the output. It would also be nice to have the eigen vectors come out as column vectors. Currently they are row vectors. This would bring more similarity to other libraries, e.g., numpy, matlab
Best Regards
Edited by t Rock