5#ifndef LINE_API_MAM_MAP_MOMENT_EXTRA_H
6#define LINE_API_MAM_MAP_MOMENT_EXTRA_H
60namespace momextradetail {
64std::vector<T> right_solve_negD0(
const Matrix<T>& D0,
const std::vector<T>& v) {
65 const std::size_t n = D0.rows();
66 Matrix<T> A(n, n, num_traits<T>::from_int(0));
68 for (std::size_t i = 0; i < n; ++i)
69 for (std::size_t j = 0; j < n; ++j) A(i, j) = -D0(j, i);
78 const std::size_t n = m.
D0.rows();
79 if (n == 0 || m.
D0.cols() != n)
throw InputError(
"map_factorial_moment: D0 must be square");
81 for (std::size_t i = 0; i < k; ++i) x = momextradetail::right_solve_negD0(m.
D0, x);
83 for (std::size_t i = 0; i < n; ++i) s += x[i];
85 for (std::size_t i = 2; i <= k; ++i) fact *= num_traits<T>::from_int(
static_cast<long>(i));
98 const std::size_t n = m.
D0.rows();
99 if (n == 0 || m.
D0.cols() != n)
throw InputError(
"map_joint_moment: D0 must be square");
100 if (m.
D1.rows() != n || m.
D1.cols() != n)
101 throw InputError(
"map_joint_moment: D1 must match D0");
104 for (std::size_t i = 0; i < k; ++i) x = momextradetail::right_solve_negD0(m.
D0, x);
107 x = momextradetail::right_solve_negD0(m.
D0, x);
109 for (std::size_t j = 0; j < n; ++j) {
111 for (std::size_t i = 0; i < n; ++i) s += x[i] * m.
D1(i, j);
114 for (std::size_t i = 0; i < l; ++i) y = momextradetail::right_solve_negD0(m.
D0, y);
117 for (std::size_t i = 0; i < n; ++i) s += y[i];
119 for (std::size_t i = 2; i <= k; ++i) fact *= num_traits<T>::from_int(
static_cast<long>(i));
120 for (std::size_t i = 2; i <= l; ++i) fact *= num_traits<T>::from_int(
static_cast<long>(i));
127 const std::size_t n = D0.
rows();
128 if (n == 0 || D0.
cols() != n)
throw InputError(
"mmap_infgen: D0 must be square");
130 for (std::size_t c = 0; c < Dk.size(); ++c) {
131 if (Dk[c].rows() != n || Dk[c].cols() != n)
132 throw InputError(
"mmap_infgen: every arrival matrix must match D0");
133 for (std::size_t i = 0; i < n; ++i)
134 for (std::size_t j = 0; j < n; ++j) Q(i, j) += Dk[c](i, j);
157 const std::size_t na = D0a.
rows(), ns = D0s.
rows();
158 if (na == 0 || ns == 0 || D0a.
cols() != na || D1a.
rows() != na || D1a.
cols() != na ||
159 D0s.
cols() != ns || D1s.
rows() != ns || D1s.
cols() != ns)
160 throw InputError(
"qbd_blocks_mapmap1: the two MAPs must be square and self-consistent");
162 const std::size_t m = na * ns;
167 for (std::size_t i = 0; i < na; ++i)
168 for (std::size_t j = 0; j < na; ++j)
169 for (std::size_t k = 0; k < ns; ++k) {
170 (*F)(i * ns + k, j * ns + k) += D1a(i, j);
171 (*L)(i * ns + k, j * ns + k) += D0a(i, j);
173 for (std::size_t i = 0; i < na; ++i)
174 for (std::size_t k = 0; k < ns; ++k)
175 for (std::size_t l = 0; l < ns; ++l) {
176 (*B)(i * ns + k, i * ns + l) += D1s(k, l);
177 (*L)(i * ns + k, i * ns + l) += D0s(k, l);
The exception types the port throws.
LU factorization with partial pivoting, templated on the number type.
Markovian arrival process descriptors: stationary vectors, rate, moments, autocorrelation and the ind...
Dense matrix and non-owning view.
T map_joint_moment(const Map< T > &m, std::size_t k, std::size_t l)
k!
T map_factorial_moment(const Map< T > &m, std::size_t k)
k!
std::vector< T > map_pie(const Map< T > &m)
Phase distribution seen by an arriving job, pie = pi D1 / (pi D1 e).
void qbd_blocks_mapmap1(const Matrix< T > &D0a, const Matrix< T > &D1a, const Matrix< T > &D0s, const Matrix< T > &D1s, Matrix< T > *B, Matrix< T > *L, Matrix< T > *F)
The QBD blocks of a MAP/MAP/1 queue: backward, local and forward.
Matrix< T > mmap_infgen(const Matrix< T > &D0, const std::vector< Matrix< T > > &Dk)
The generator of an MMAP: D0 plus every marked arrival matrix.
std::vector< T > solve(const Matrix< T > &A, const std::vector< T > &b)
Convenience: solve Ax = b, leaving A and b untouched.
Number-type abstraction for the templated API port.
A MAP as the pair of matrices (D0, D1).