diff --git a/permutation.cc b/permutation.cc index b83b455..04b178d 100644 --- a/permutation.cc +++ b/permutation.cc @@ -16,6 +16,7 @@ along with this program. If not, see . */ +#include "vec.h" #include "permutation.h" #include #include diff --git a/vec.cc b/vec.cc index 1e46a9a..13379ff 100644 --- a/vec.cc +++ b/vec.cc @@ -26,7 +26,6 @@ #include #include #include "vec.h" -#include "qsort.h" #include @@ -807,25 +806,6 @@ NRVec >::otimes(const NRVec > &b, cons return result; } -template -int NRVec::sort(int direction, int from, int to, int *perm) { - NOT_GPU(*this); - - copyonwrite(); - if(to == -1) to = nn - 1; - if(direction) return memqsort<1, NRVec, int, int>(*this, perm, from, to); - else return memqsort<0, NRVec, int, int>(*this, perm, from, to); -} - -template -int NRVec::sort(int direction, NRPerm &perm) -{ -if(nn!=perm.size()) laerror("incompatible vector and permutation"); -perm.identity(); -int r=sort(direction,0,nn-1,&perm[1]); -return r; -} - template<> NRVec > complexify(const NRVec &rhs) { NRVec > r(rhs.size(), rhs.getlocation()); diff --git a/vec.h b/vec.h index 478e048..02e1bad 100644 --- a/vec.h +++ b/vec.h @@ -476,6 +476,7 @@ public: #include "smat.h" #include "sparsemat.h" #include "sparsesmat.h" +#include "qsort.h" @@ -485,6 +486,26 @@ public: namespace LA { +template +int NRVec::sort(int direction, int from, int to, int *perm) { + NOT_GPU(*this); + + copyonwrite(); + if(to == -1) to = nn - 1; + if(direction) return memqsort<1, NRVec, int, int>(*this, perm, from, to); + else return memqsort<0, NRVec, int, int>(*this, perm, from, to); +} + +template +int NRVec::sort(int direction, NRPerm &perm) +{ +if(nn!=perm.size()) laerror("incompatible vector and permutation"); +perm.identity(); +int r=sort(direction,0,nn-1,&perm[1]); +return r; +} + + /***************************************************************************//** * indexing operator giving the element at given position with range checking in * the DEBUG mode