Debian Codegraph @

src/util.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2016, Mike Walters <[email protected]>
3 * Copyright (C) 2016, Jared Boone, ShareBrained Technology, Inc.
4 *
5 * This file is part of inspectrum.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #pragma once
22 #include <algorithm>
23 #include <complex>
24 #include <map>
25 #include <math.h>
26 #include <sstream>
27
28 static const double Taucxx . . $ Tau. = M_PIcxx . . $ `<external>/11263917310783833665/math.h:1289:10`! * 2.0;
29
30 template <class T> const T& clampcxx . . $ clamp(3dbe0c69cb86ae06). (const T& value, const T& min, const T& max)
31 {
32 return stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(max, stdcxx . . $ std/::maxcxx . . $ std/max(7d979dd22a97e265).(min, value));
33 }
34
35 template<class Iter>
36 struct iter_pair_rangecxx . . $ iter_pair_range# : stdcxx . . $ std/::paircxx . . $ std/pair#<Iter,Iter> {
37 iter_pair_rangecxx . . $ iter_pair_range#`iter_pair_range<Iter>`(81e457f5e129d1b7).(stdcxx . . $ std/::paircxx . . $ std/pair#<Iter,Iter> const& x) : stdcxx . . $ std/::paircxx . . $ std/pair#<Iter,Iter>(x) { }
38 Iter begincxx . . $ iter_pair_range#begin(8f5363d873dd4781).() const {
39 return this->firstcxx . . $ std/pair#first.;
40 }
41 Iter endcxx . . $ iter_pair_range#end(8f5363d873dd4781).() const {
42 return this->secondcxx . . $ std/pair#second.;
43 }
44 };
45
46 template<class Iter>
47 inline iter_pair_rangecxx . . $ iter_pair_range#<Iter> as_rangecxx . . $ as_range(8d1e2b332792edde).(stdcxx . . $ std/::paircxx . . $ std/pair#<Iter,Iter> const& x)
48 {
49 return iter_pair_rangecxx . . $ iter_pair_range#<Iter>(x);
50 }
51
52 template<class T>
53 struct range_tcxx . . $ range_t# {
54 T minimumcxx . . $ range_t#minimum.;
55 T maximumcxx . . $ range_t#maximum.;
56
57 range_tcxx . . $ range_t#<T>& operatorcxx . . $ range_t#`operator=`(dd2ccbbcde53e176).=(const range_tcxx . . $ range_t#<T> &other) {
58 minimumcxx . . $ range_t#minimum. = other.minimumcxx . . $ range_t#minimum.;
59 maximumcxx . . $ range_t#maximum. = other.maximumcxx . . $ range_t#maximum.;
60 return *this;
61 }
62
63 range_tcxx . . $ range_t#<T>& operatorcxx . . $ range_t#`operator=`(b7f9b018042febfd).=(const stdcxx . . $ std/::initializer_listcxx . . $ std/initializer_list#<T> &other) {
64 if (other.sizecxx . . $ std/initializer_list#size(fe4d2d262d4164a8).() ==cxx . . $ `operator==`(3fb0852ae8c51f7). 2) {
65 minimumcxx . . $ range_t#minimum. = *cxx . . $ `operator*`(af256f10665d954b).other.begincxx . . $ std/initializer_list#begin(1016ee5406d91ab9).();
66 maximumcxx . . $ range_t#maximum. = *cxx . . $ `operator*`(d6f0e65245436ed5).(other.begincxx . . $ std/initializer_list#begin(1016ee5406d91ab9).() +cxx . . $ operator+(e749d9d4a2ebbeba). 1);
67 }
68 return *this;
69 }
70
71 const T lengthcxx . . $ range_t#length(f448638088200dcb).() {
72 return maximumcxx . . $ range_t#maximum. -cxx . . $ operator-(e229ca25d6519380). minimumcxx . . $ range_t#minimum.;
73 }
74
75 const T& clipcxx . . $ range_t#clip(2e044cb6e7a82418).(const T& value) const {
76 return clampcxx . . $ clamp(3dbe0c69cb86ae06).(value, minimumcxx . . $ range_t#minimum., maximumcxx . . $ range_t#maximum.);
77 }
78
79 void reset_if_outsidecxx . . $ range_t#reset_if_outside(71e568917a29963e).(T& value, const T& reset_value) const {
80 if( (value <cxx . . $ `operator<`(d4e70fe9dd6030fb). minimumcxx . . $ range_t#minimum. ) ||
81 (value >cxx . . $ `operator>`(c560f0e741f3c9c9). maximumcxx . . $ range_t#maximum. ) ) {
82 value = reset_value;
83 }
84 }
85
86 bool below_rangecxx . . $ range_t#below_range(8877ebe272b9620d).(const T& value) const {
87 return value <cxx . . $ `operator<`(d419c695eec36cd2). minimumcxx . . $ range_t#minimum.;
88 }
89
90 bool containscxx . . $ range_t#contains(8877ebe272b9620d).(const T& value) const {
91 // TODO: Subtle gotcha here! Range test doesn't include maximum!
92 return (value >=cxx . . $ `operator>=`(a35ad4c7c95d8071). minimumcxx . . $ range_t#minimum.) && (value <cxx . . $ `operator<`(9835b8dbb8c249ee). maximumcxx . . $ range_t#maximum.);
93 }
94
95 bool out_of_rangecxx . . $ range_t#out_of_range(8877ebe272b9620d).(const T& value) const {
96 // TODO: Subtle gotcha here! Range test in contains() doesn't include maximum!
97 return !containscxx . . $ range_t#contains(8877ebe272b9620d).(value);
98 }
99 };
100
101 stdcxx . . $ std/::stringcxx . . $ std/string# formatSIValuecxx . . $ formatSIValue(14a4da2464e078e0).(float value);
102
103 template<typename T> const char* getFileNameFiltercxx . . $ getFileNameFilter(33a1f659e94feb42).();