LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
fj_xmax_2.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_FJ_XMAX_2_H
6
#define LINE_API_FJ_XMAX_2_H
7
8
/**
9
* @file
10
* @ingroup api_fj
11
* Expected maximum of two independent, possibly unequal-rate exponentials.
12
*
13
* Templated port of matlab/src/api/fj/fj_xmax_2.m, cross-checked against
14
* FJ_xmax.fj_xmax_2 in jar/src/main/java/jline/api/fj/FJ_xmax.java
15
* (identical).
16
*
17
* Y_2^max = 1/lambda1 + 1/lambda2 - 1/(lambda1 + lambda2)
18
*
19
* Rational, hence exact in the field. At lambda1 = lambda2 = mu it collapses
20
* to (3/2)/mu = H_2/mu, which is fj_xmax_exp at K = 2.
21
*/
22
23
#include "
line/api/fj/fj_types.h
"
24
#include "
line/num/number.h
"
25
#include "
line/util/error.h
"
26
27
namespace
line
{
28
namespace
fj
{
29
30
/**
31
* @brief Expected maximum of two independent, possibly unequal-rate
32
* exponentials.
33
*
34
* @param lambda1 rate of the first branch, > 0
35
* @param lambda2 rate of the second branch, > 0
36
* @return expected maximum of the two exponentials
37
*/
38
template
<
class
T>
39
T
fj_xmax_2
(
const
T& lambda1,
const
T& lambda2) {
40
const
T zero =
num_traits<T>::from_int
(0), one =
num_traits<T>::from_int
(1);
41
if
(lambda1 <= zero || lambda2 <= zero)
throw
InputError
(
"fj_xmax_2: the rates must be positive"
);
42
return
one / lambda1 + one / lambda2 - one / (lambda1 + lambda2);
43
}
44
45
/** Equal-rate overload, matching MATLAB's single-argument call. */
46
template
<
class
T>
47
T
fj_xmax_2
(
const
T& lambda) {
48
return
fj_xmax_2
(lambda, lambda);
49
}
50
51
}
// namespace fj
52
}
// namespace line
53
54
#endif
// LINE_API_FJ_XMAX_2_H
line::InputError::InputError
InputError(const std::string &what)
Definition
error.h:39
error.h
The exception types the port throws.
fj_types.h
Shared return types and arithmetic helpers for the templated fork-join port.
line::fj
Definition
fj_amva.h:34
line::fj::fj_xmax_2
T fj_xmax_2(const T &lambda1, const T &lambda2)
Expected maximum of two independent, possibly unequal-rate exponentials.
Definition
fj_xmax_2.h:39
line
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
line::num_traits
Definition
number.h:111
include
line
api
fj
fj_xmax_2.h
Generated by
1.18.0