LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
moment_upfactorial_from_factorial.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_UPFACTORIAL_FROM_FACTORIAL_H
6#define LINE_API_MOMENT_MOMENT_UPFACTORIAL_FROM_FACTORIAL_H
7
8/**
9 * @file
10 * @ingroup api_moment
11 * Rising-factorial moments from falling-factorial moments, via the Lah numbers.
12 *
13 * Templated port of matlab/src/api/moment/moment_upfactorial_from_factorial.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"
27
28namespace line {
29namespace moment {
30
31/** fp_0 = 1; fp_i = sum_k L(i,k) f_k for i >= 1. */
32template <class T>
33std::vector<T> moment_upfactorial_from_factorial(const std::vector<T>& f) {
34 const int n = static_cast<int>(f.size()) - 1;
36 std::vector<T> fp(f.size(), num_traits<T>::from_int(0));
37 fp[0] = num_traits<T>::from_int(1);
38 for (int i = 1; i <= n; ++i)
39 for (int k = 1; k <= i; ++k)
40 fp[static_cast<std::size_t>(i)] += L(i, k) * f[static_cast<std::size_t>(k)];
41 return fp;
42}
43
44} // namespace moment
45} // namespace line
46
47#endif
The exception types the port throws.
Dense matrix and non-owning view.
Unsigned Lah numbers.
std::vector< T > moment_upfactorial_from_factorial(const std::vector< T > &f)
fp_0 = 1; fp_i = sum_k L(i,k) f_k for i >= 1.
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.
Definition moment_lah.h:31
Number-type abstraction for the templated API port.
Population-vector enumeration and combinatorics.