LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
aph_convseq.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_APH_CONVSEQ_H
6#define LINE_API_MAM_APH_CONVSEQ_H
7
8/**
9 * @file
10 * @ingroup api_mam
11 * Convolution of a sequence of matrix-exponential laws.
12 *
13 * Port of `matlab/lib/kpctoolbox/aph/aph_convseq.m`: fold `aph_simplify` with
14 * the sequence pattern over the list, left to right. The reference takes a flat
15 * cell array of alternating alpha and T entries and special-cases a list of one
16 * pair by returning it unchanged; here the list is a vector of pairs, so the
17 * one-element case falls out of the fold and needs no arm of its own.
18 *
19 * The composite order is the SUM of the orders, so a long activity sequence of
20 * high-order fits produces a large generator. That is the reference's cost too
21 * -- neither it nor this reduces the representation -- and it is why the LN
22 * caller fits each term to a low-order APH before convolving.
23 */
24
25#include <cstddef>
26#include <vector>
27
29#include "line/num/number.h"
30#include "line/util/error.h"
31
32namespace line {
33namespace mam {
34
35/** Convolve the sequence, i.e. the law of the sum of independent terms. */
36template <class T>
37AphPair<T> aph_convseq(const std::vector<AphPair<T>>& seq) {
38 if (seq.empty()) throw InputError("aph_convseq: the sequence is empty");
39 const T one = num_traits<T>::from_int(1);
40 AphPair<T> acc = seq[0];
41 for (std::size_t i = 1; i < seq.size(); ++i)
42 acc = aph_simplify(acc, seq[i], one, one, AphPattern::Sequence);
43 return acc;
44}
45
46} // namespace mam
47} // namespace line
48
49#endif // LINE_API_MAM_APH_CONVSEQ_H
Composition of two matrix-exponential distributions given in (alpha, T) form.
InputError(const std::string &what)
Definition error.h:39
The exception types the port throws.
AphPair< T > aph_convseq(const std::vector< AphPair< T > > &seq)
Convolve the sequence, i.e.
Definition aph_convseq.h:37
AphPair< T > aph_simplify(const AphPair< T > &d1, const AphPair< T > &d2, const T &p1, const T &p2, AphPattern pattern)
Compose two matrix-exponential laws, as aph_simplify.m does.
Number-type abstraction for the templated API port.
A matrix-exponential law in (alpha, S) form: initial vector and subgenerator.