NRVec sorting moved to .h to be available for newly derived non-plain data types
This commit is contained in:
21
vec.h
21
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<typename T>
|
||||
int NRVec<T>::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<T>, int, int>(*this, perm, from, to);
|
||||
else return memqsort<0, NRVec<T>, int, int>(*this, perm, from, to);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
int NRVec<T>::sort(int direction, NRPerm<int> &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
|
||||
|
||||
Reference in New Issue
Block a user