LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
moment_raw_from_central.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_MOMENT_MOMENT_RAW_FROM_CENTRAL_H
6
#define LINE_API_MOMENT_MOMENT_RAW_FROM_CENTRAL_H
7
8
/**
9
* @file
10
* @ingroup api_moment
11
* Raw moments from central moments and the mean.
12
*
13
* Templated port of matlab/src/api/moment/moment_raw_from_central.m. Every operation is integer
14
* or rational, so the exact instantiation returns the transform with no
15
* rounding at all. That matters more here than almost anywhere else in the API:
16
* the alternating binomial sums of the moment conversions cancel
17
* catastrophically in double arithmetic once the order grows.
18
*/
19
20
#include <vector>
21
22
#include "
line/num/number.h
"
23
#include "
line/util/error.h
"
24
#include "
line/util/matrix.h
"
25
#include "
line/util/population.h
"
26
27
namespace
line
{
28
namespace
moment
{
29
30
/** m_i = sum_k C(i,k) mc_k m1^(i-k). */
31
template
<
class
T>
32
std::vector<T>
moment_raw_from_central
(
const
std::vector<T>&
mc
,
const
T& m1) {
33
const
std::size_t n =
mc
.size();
34
std::vector<T> m(n,
num_traits<T>::from_int
(0));
35
for
(std::size_t i = 0; i < n; ++i)
36
for
(std::size_t k = 0; k <= i; ++k)
37
m[i] +=
num_nck<T>
(
static_cast<
int
>
(i),
static_cast<
int
>
(k)) *
mc
[k] *
38
num_pow_int
(m1,
static_cast<
unsigned
>
(i - k));
39
return
m;
40
}
41
42
}
// namespace moment
43
}
// namespace line
44
45
#endif
error.h
The exception types the port throws.
matrix.h
Dense matrix and non-owning view.
line::mc
Definition
ctmc_bicgstab.h:59
line::moment
Definition
moment_apply.h:28
line::moment::moment_raw_from_central
std::vector< T > moment_raw_from_central(const std::vector< T > &mc, const T &m1)
m_i = sum_k C(i,k) mc_k m1^(i-k).
Definition
moment_raw_from_central.h:32
line
Definition
aoi_dist2ph.h:52
line::num_pow_int
T num_pow_int(const T &base, unsigned e)
Integer power, valid in any field (no transcendental requirement).
Definition
number.h:192
line::num_nck
T num_nck(int n, int k)
Binomial coefficient as a value of T, by the Pascal recurrence.
Definition
population.h:87
number.h
Number-type abstraction for the templated API port.
population.h
Population-vector enumeration and combinatorics.
line::num_traits
Definition
number.h:111
include
line
api
moment
moment_raw_from_central.h
Generated by
1.18.0