LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
moment_stirling1.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_STIRLING1_H
6
#define LINE_API_MOMENT_MOMENT_STIRLING1_H
7
8
/**
9
* @file
10
* @ingroup api_moment
11
* Signed Stirling numbers of the first kind.
12
*
13
* Templated port of matlab/src/api/moment/moment_stirling1.m. Every operation is integer or
14
* rational, so the exact instantiation returns the transform with no rounding:
15
* moment conversions are exactly where double arithmetic hurts, since the
16
* alternating binomial sums cancel catastrophically at high order.
17
*/
18
19
#include <vector>
20
21
#include "
line/num/number.h
"
22
#include "
line/util/error.h
"
23
#include "
line/util/matrix.h
"
24
#include "
line/util/population.h
"
25
#include "
line/api/moment/moment_stirlingcycle.h
"
26
27
namespace
line
{
28
namespace
moment
{
29
30
31
/** s(i,j) = (-1)^(i-j) sigma(i,j). */
32
template
<
class
T>
33
Matrix<T>
moment_stirling1
(
int
n) {
34
Matrix<T>
sigma =
moment_stirlingcycle<T>
(n);
35
Matrix<T>
s(n + 1, n + 1,
num_traits<T>::from_int
(0));
36
for
(
int
i = 0; i <= n; ++i)
37
for
(
int
j = 0; j <= i; ++j)
38
s(i, j) = ((i - j) % 2 == 0) ? sigma(i, j) : -sigma(i, j);
39
return
s;
40
}
41
42
}
// namespace moment
43
}
// namespace line
44
45
#endif
line::Matrix
Definition
matrix.h:56
error.h
The exception types the port throws.
matrix.h
Dense matrix and non-owning view.
moment_stirlingcycle.h
Unsigned Stirling numbers of the first kind (cycle numbers), orders 0..n.
line::moment
Definition
moment_apply.h:28
line::moment::moment_stirling1
Matrix< T > moment_stirling1(int n)
s(i,j) = (-1)^(i-j) sigma(i,j).
Definition
moment_stirling1.h:33
line::moment::moment_stirlingcycle
Matrix< T > moment_stirlingcycle(int n)
sigma(i,j), (n+1) x (n+1) lower triangular, sigma(0,0) = 1.
Definition
moment_stirlingcycle.h:31
line
Definition
aoi_dist2ph.h:52
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_stirling1.h
Generated by
1.18.0