LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
map_count_mean.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_MAP_COUNT_MEAN_H
6#define LINE_API_MAM_MAP_COUNT_MEAN_H
7
8/**
9 * @file
10 * @ingroup api_mam
11 * Mean of the counting process of a MAP at resolution t.
12 *
13 * Templated port of matlab/lib/kpctoolbox/map/map_count_mean.m. The number of
14 * arrivals in a window of length t has stationary mean lambda t, with lambda
15 * the stationary arrival rate pi D1 e, so the whole function is one linear
16 * solve and a product.
17 *
18 * ARITHMETIC: exact. No exponential appears, and the mean of the counts is a
19 * rational function of the entries of (D0, D1) -- which makes it the natural
20 * consistency check on the counting-process functions that do need expm
21 * (map_count_var, map_count_moment), since M1 from map_count_moment must
22 * reproduce this value to the exponential's tolerance.
23 */
24
25#include <cstddef>
26#include <vector>
27
29#include "line/num/number.h"
30#include "line/util/error.h"
31#include "line/util/matrix.h"
32
33namespace line {
34namespace mam {
35
36/**
37 * @brief Mean of the counting process of a MAP at resolution t.
38 *
39 * @param m the MAP (D0, D1)
40 * @param t window lengths
41 * @return lambda t for each window length, in the order of t
42 */
43template <class T>
44std::vector<T> map_count_mean(const Map<T>& m, const std::vector<T>& t) {
45 const T lam = map_lambda(m);
46 std::vector<T> out;
47 out.reserve(t.size());
48 for (std::size_t k = 0; k < t.size(); ++k) {
49 if (t[k] < num_traits<T>::from_int(0))
50 throw InputError("map_count_mean: negative window length");
51 out.push_back(lam * t[k]);
52 }
53 return out;
54}
55
56} // namespace mam
57} // namespace line
58
59#endif // LINE_API_MAM_MAP_COUNT_MEAN_H
InputError(const std::string &what)
Definition error.h:39
The exception types the port throws.
Markovian arrival process descriptors: stationary vectors, rate, moments, autocorrelation and the ind...
Dense matrix and non-owning view.
std::vector< T > map_count_mean(const Map< T > &m, const std::vector< T > &t)
Mean of the counting process of a MAP at resolution t.
T map_lambda(const Map< T > &m)
Stationary arrival rate, lambda = pi D1 e.
Definition map_moment.h:79
Number-type abstraction for the templated API port.
A MAP as the pair of matrices (D0, D1).
Definition map_moment.h:53