LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
npfqn_types.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012-2026, QORE Lab, Imperial College London
3
* All rights reserved.
4
*/
5
#ifndef LINE_API_NPFQN_TYPES_H
6
#define LINE_API_NPFQN_TYPES_H
7
8
/**
9
* @file
10
* @ingroup api_npfqn
11
* Shared arithmetic helpers for the templated npfqn port.
12
*
13
* The non-product-form traffic approximations in matlab/src/api/npfqn/ do not
14
* share a single return type the way the qsys family does, so each ported
15
* function declares its own result struct in its own header. What they do
16
* share is a handful of ADL wrappers around the transcendental functions and
17
* the finiteness test, which are collected here so that the same incantation
18
* serves double, cpp_bin_float and mpfr. This header mirrors the role of
19
* line/api/qsys/qsys_types.h and adds no algorithm of its own.
20
*/
21
22
#include <cmath>
23
#include <cstddef>
24
25
#include <boost/math/constants/constants.hpp>
26
#include <boost/math/special_functions/erf.hpp>
27
#include <boost/math/special_functions/fpclassify.hpp>
28
29
#include "
line/num/number.h
"
30
#include "
line/util/error.h
"
31
32
namespace
line
{
33
namespace
npfqn
{
34
35
namespace
detail {
36
37
/** exp(v), resolved by ADL so double, cpp_bin_float and mpfr all work. */
38
template
<
class
T>
39
inline
T num_exp(
const
T& v) {
40
using
std::exp;
41
return
exp(v);
42
}
43
44
/** sqrt(v), resolved by ADL. */
45
template
<
class
T>
46
inline
T num_sqrt(
const
T& v) {
47
using
std::sqrt;
48
return
sqrt(v);
49
}
50
51
/** base^exponent for a real-valued exponent, resolved by ADL. */
52
template
<
class
T>
53
inline
T num_pow(
const
T& base,
const
T& exponent) {
54
using
std::pow;
55
return
pow(base, exponent);
56
}
57
58
/** Complementary error function, from Boost.Math so that it is type generic. */
59
template
<
class
T>
60
inline
T num_erfc(
const
T& v) {
61
return
boost::math::erfc(v);
62
}
63
64
/** MATLAB isfinite: false for +-Inf and NaN. Always true in an exact field. */
65
template
<
class
T>
66
inline
bool
num_isfinite(
const
T& v) {
67
return
boost::math::isfinite(v);
68
}
69
70
template
<>
71
inline
bool
num_isfinite<Rational>(
const
Rational
&) {
72
return
true
;
// a rational has neither an infinity nor a NaN
73
}
74
75
/** MATLAB isnan. Always false in an exact field. */
76
template
<
class
T>
77
inline
bool
num_isnan(
const
T& v) {
78
return
boost::math::isnan(v);
79
}
80
81
template
<>
82
inline
bool
num_isnan<Rational>(
const
Rational
&) {
83
return
false
;
84
}
85
86
template
<
class
T>
87
inline
const
T& num_max(
const
T& a,
const
T& b) {
88
return
a < b ? b : a;
89
}
90
91
template
<
class
T>
92
inline
const
T& num_min(
const
T& a,
const
T& b) {
93
return
a < b ? a : b;
94
}
95
96
}
// namespace detail
97
98
}
// namespace npfqn
99
}
// namespace line
100
101
#endif
// LINE_API_NPFQN_TYPES_H
error.h
The exception types the port throws.
line::npfqn
Definition
npfqn_bnd_bgt.h:76
line
Definition
aoi_dist2ph.h:52
line::Rational
boost::multiprecision::number< boost::multiprecision::cpp_rational_backend, boost::multiprecision::et_off > Rational
Definition
number.h:76
number.h
Number-type abstraction for the templated API port.
include
line
api
npfqn
npfqn_types.h
Generated by
1.18.0