LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
map2mmpp.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_MAM_MAP2MMPP_H
6#define LINE_API_MAM_MAP2MMPP_H
7
8/**
9 * @file
10 * @ingroup api_mam
11 * Read a MAP as an MMPP (matlab/lib/kpctoolbox/map/map2mmpp.m).
12 *
13 * Returns the modulating generator Q = D0 + D1 and the arrival-rate matrix
14 * LAMBDA = D1. The representation is an MMPP only when D1 is diagonal; MATLAB
15 * emits a warning in that case and returns anyway, whereas this port reports
16 * the off-diagonal mass through the result struct so the caller decides.
17 *
18 * Pure additions and copies, exact at Rational: no transcendental gate.
19 */
20
22#include "line/num/number.h"
23#include "line/util/matrix.h"
24
25namespace line {
26namespace mam {
27
28/** Result of map2mmpp. */
29template <class T>
31 Matrix<T> Q; ///< modulating generator D0 + D1
32 Matrix<T> LAMBDA; ///< arrival rates D1
33 T offdiag_norm; ///< max |D1(i,j)| over i != j; zero iff a true MMPP
34 bool is_mmpp; ///< offdiag_norm == 0
35};
36
37/** Modulating generator and arrival-rate matrix of a MAP read as an MMPP. */
38template <class T>
40 const T zero = num_traits<T>::from_int(0);
42 r.Q = map_infgen(m);
43 r.LAMBDA = m.D1;
44 r.offdiag_norm = zero;
45 for (std::size_t i = 0; i < m.D1.rows(); ++i)
46 for (std::size_t j = 0; j < m.D1.cols(); ++j) {
47 if (i == j) continue;
48 const T a = num_abs(T(m.D1(i, j)));
49 if (a > r.offdiag_norm) r.offdiag_norm = a;
50 }
51 r.is_mmpp = (r.offdiag_norm == zero);
52 return r;
53}
54
55} // namespace mam
56} // namespace line
57
58#endif // LINE_API_MAM_MAP2MMPP_H
Markovian arrival process descriptors: stationary vectors, rate, moments, autocorrelation and the ind...
Dense matrix and non-owning view.
Matrix< T > map_infgen(const Map< T > &m)
Generator of the underlying phase process, D0 + D1.
Definition map_moment.h:62
Map2mmppResult< T > map2mmpp(const Map< T > &m)
Modulating generator and arrival-rate matrix of a MAP read as an MMPP.
Definition map2mmpp.h:39
T num_abs(const T &v)
Definition number.h:172
Number-type abstraction for the templated API port.
Result of map2mmpp.
Definition map2mmpp.h:30
bool is_mmpp
offdiag_norm == 0
Definition map2mmpp.h:34
T offdiag_norm
max |D1(i,j)| over i != j; zero iff a true MMPP
Definition map2mmpp.h:33
Matrix< T > LAMBDA
arrival rates D1
Definition map2mmpp.h:32
Matrix< T > Q
modulating generator D0 + D1
Definition map2mmpp.h:31
A MAP as the pair of matrices (D0, D1).
Definition map_moment.h:53
Matrix< T > D1
Definition map_moment.h:55