NRVec sorting moved to .h to be available for newly derived non-plain data types

This commit is contained in:
2022-06-09 21:36:42 +02:00
parent 3a163ae81f
commit 23d70d3808
3 changed files with 22 additions and 20 deletions

21
vec.h
View File

@@ -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