| 1 |
/* ExtendedReal.cpp |
| 2 |
* |
| 3 |
* Copyright (C) 2025 David Weenink |
| 4 |
* |
| 5 |
* This code is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation; either version 3 of the License, or (at |
| 8 |
* your option) any later version. |
| 9 |
* |
| 10 |
* This code is distributed in the hope that it will be useful, but |
| 11 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
#include "ExtendedReal.h" |
| 20 |
#include "melder.h" |
| 21 |
#include "median_of_ninthers.h" |
| 22 |
|
| 23 |
|
| 24 |
#include "oo_DESTROY.h" |
| 25 |
#include "ExtendedReal_def.h" |
| 26 |
#include "oo_COPY.h" |
| 27 |
#include "ExtendedReal_def.h" |
| 28 |
#include "oo_EQUAL.h" |
| 29 |
#include "ExtendedReal_def.h" |
| 30 |
#include "oo_CAN_WRITE_AS_ENCODING.h" |
| 31 |
#include "ExtendedReal_def.h" |
| 32 |
#include "oo_WRITE_TEXT.h" |
| 33 |
#include "ExtendedReal_def.h" |
| 34 |
#include "oo_READ_TEXT.h" |
| 35 |
#include "ExtendedReal_def.h" |
| 36 |
#include "oo_WRITE_BINARY.h" |
| 37 |
#include "ExtendedReal_def.h" |
| 38 |
#include "oo_READ_BINARY.h" |
| 39 |
#include "ExtendedReal_def.h" |
| 40 |
#include "oo_DESCRIPTION.h" |
| 41 |
#include "ExtendedReal_def.h" |
| 42 |
|
| 43 |
/* |
| 44 |
autoVEC vector_to_VEC (constvectorview<structExtendedReal> const& v) { |
| 45 |
autoVEC vec = raw_VEC (v.size); |
| 46 |
for (integer i = 1; i <= v.size; i ++) |
| 47 |
vec [i] = v [i].real; |
| 48 |
return vec; |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
template <typename structT> |
| 53 |
void NUMselect (vector<structT> const& v, integer kth_asIfSorted) { |
| 54 |
adaptiveQuickselect (v.asArgumentToFunctionThatExpectsZeroBasedArray(), kth_asIfSorted - 1, v.size); |
| 55 |
} |
| 56 |
|
| 57 |
template <typename structT> |
| 58 |
structT& NUMget_kth_inplace (vector<structT> const& v, integer kth_asIfSorted) { |
| 59 |
NUMselect (v, kth_asIfSorted); |
| 60 |
return v[kth_asIfSorted]; |
| 61 |
} |
| 62 |
|
| 63 |
template <typename structT> |
| 64 |
structT& NUMget_kth (constvectorview<structT> const& v, integer kth_asIfSorted) { |
| 65 |
autovector<structT> vcopy = newvectorcopy (v); |
| 66 |
return NUMget_kth_inplace (vcopy.get(), kth_asIfSorted); |
| 67 |
} |
| 68 |
|
| 69 |
template <typename structT> |
| 70 |
void NUMselect (constvectorview<structT> const& v, integer kth_asIfSorted) { |
| 71 |
autovector<structT> vcopy = newvectorcopy (v); |
| 72 |
NUMselect (vcopy.get(), kth_asIfSorted); |
| 73 |
} |
| 74 |
*/ |
| 75 |
|
| 76 |
/* End of file ExtendedReal.cpp */ |