5#ifndef LINE_API_MOMENT_MOMENT_HOUSEMATRIX_H
6#define LINE_API_MOMENT_MOMENT_HOUSEMATRIX_H
77 throw InputError(
"moment_housematrix: unknown edge " + edge);
84 throw InputError(
"moment_housematrix: the maximum order n must be a nonnegative integer");
87 Matrix<T> Tm(
static_cast<std::size_t
>(n) + 1,
static_cast<std::size_t
>(n) + 1, zero);
97 for (
int i = 0; i <= n; ++i)
98 for (
int j = 0; j <= i; ++j)
99 Tm(i, j) = ((i - j) % 2 == 0) ? S(i, j) : -S(i, j);
104 for (
int i = 0; i <= n; ++i)
109 for (
int i = 0; i <= n; ++i) Tm(i, i) = num_factorial<T>(
static_cast<unsigned>(i));
115 for (
int i = 1; i <= n; ++i)
116 for (
int k = 1; k <= i; ++k)
125 for (
int i = 1; i <= n; ++i)
126 for (
int k = 1; k <= i; ++k) {
136 for (
int i = 1; i <= n; ++i)
137 for (
int k = i; k <= n; ++k) {
144 throw InputError(
"moment_housematrix: unknown edge");
157 for (std::size_t i = 0; i < v.size(); ++i)
158 for (std::size_t j = 0; j < v.size(); ++j) r[i] += A(i, j) * v[j];
The exception types the port throws.
Dense matrix and non-owning view.
Signed Stirling numbers of the first kind.
Stirling numbers of the second kind.
Unsigned Stirling numbers of the first kind (cycle numbers), orders 0..n.
Matrix< T > moment_housematrix(MomentEdge edge, int n)
(n+1)x(n+1) conversion table of the given edge.
std::vector< T > moment_apply_full(const Matrix< T > &A, const std::vector< T > &v)
Full matrix-vector product, needed because the tail edges are upper triangular.
Matrix< T > moment_stirling2(int n)
S(i,j) = j S(i-1,j) + S(i-1,j-1), S(0,0) = 1.
MomentEdge
Edge labels of the house of moments, one per MATLAB edge string.
@ UpfactorialFromFactorial
@ FactorialFromUpfactorial
@ BinomialFromNegbinomial
@ NegbinomialFromBinomial
@ UpfactorialFromNegbinomial
@ NegbinomialFromUpfactorial
Matrix< T > moment_lah(int n)
L(i,j) = L(i-1,j-1) + (i+j-1) L(i-1,j), L(0,0) = 1.
Matrix< T > moment_stirling1(int n)
s(i,j) = (-1)^(i-j) sigma(i,j).
MomentEdge moment_edge_from_string(const std::string &edge)
Parses the MATLAB edge string into its label.
Matrix< T > moment_stirlingcycle(int n)
sigma(i,j), (n+1) x (n+1) lower triangular, sigma(0,0) = 1.
Conservation laws of a layered queueing network, enumerated from its structure.
T num_factorial(unsigned n)
Factorial as a value of T.
T num_nck(int n, int k)
Binomial coefficient as a value of T, by the Pascal recurrence.
Number-type abstraction for the templated API port.
Population-vector enumeration and combinatorics.