LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
sylvester.h File Reference

The Sylvester equation A X + X B = C, and MATLAB's lyap(A,B,C). More...

#include <cstddef>
#include <memory>
#include <type_traits>
#include <vector>
#include "line/num/number.h"
#include "line/util/eig.h"
#include "line/util/error.h"
#include "line/util/linalg.h"
#include "line/util/lu.h"
#include "line/util/matrix.h"
#include "line/util/lapack.h"
Include dependency graph for sylvester.h:

Go to the source code of this file.

Classes

class  line::SchurSylvesterFactor
 A X + X B = C by Bartels-Stewart, at double. More...
class  line::SylvesterFactor< T >
 The Kronecker operator of a FIXED (A,B) pair, factorized once. More...

Namespaces

namespace  line
 Conservation laws of a layered queueing network, enumerated from its structure.

Functions

Matrix< double > line::sylvester_schur (const Matrix< double > &A, const Matrix< double > &B, const Matrix< double > &C)
 A X + X B = C by Bartels-Stewart, at double; see SchurSylvesterFactor.
template<class T>
Matrix< T > line::sylvester_solve (const Matrix< T > &A, const Matrix< T > &B, const Matrix< T > &C)
 Solve A X + X B = C for X.
template<class T>
Matrix< T > line::lyap_solve (const Matrix< T > &A, const Matrix< T > &B, const Matrix< T > &C)
 MATLAB lyap(A,B,C) solves A X + X B + C = 0, i.e.
Matrix< double > line::lyap_schur (const Matrix< double > &A, const Matrix< double > &B, const Matrix< double > &C)
 MATLAB lyap(A,B,C) at double via Bartels-Stewart: A X + X B + C = 0.

Detailed Description

The Sylvester equation A X + X B = C, and MATLAB's lyap(A,B,C).

Solved in the Kronecker form (I_m kron A + B^T kron I_n) vec(X) = vec(C) with vec column-major, so the whole thing is one LU solve of order n*m in T. That is the ONLY formulation available at every arithmetic the port offers: Bartels-Stewart needs a real Schur factorization, util/eig.h is deliberately double-only (eigenvalues of a rational matrix are algebraic, not rational), so a Schur-based solver would silently pin every caller to double. The cost is O((n m)^3) against Bartels-Stewart's O(n^3 + m^3); the callers in this port pass phase-space matrices whose order is the product of an arrival MMAP order and a total service-PH order, both small, and the whole point of the header is that Rational and Real<D> get an answer at all.

SO A DOUBLE-ONLY CALLER TAKES sylvester_schur/lyap_schur BELOW, not these, and SylvesterFactor<double> itself takes the Schur arm whenever LAPACK is present (see its comment for the dec.mmap hang that forced it). The Kronecker arm exists for the arithmetics Schur cannot reach, and the two linear-noise covariances – fluid_lyapunov and cache_rmf_lna – are double by construction, since each decides stability with eig_values first. Both once took this arm, and both grew a d^2-by-d^2 LU out of a d-by-d covariance: an Erlang(64) service made the fluid one 4096-square and it stopped finishing.

mfq_multiregime.h carries the identical Kronecker construction for Matrix<double>; it predates this header and stays where it is because it is used only from double-only code and moving it would churn two large files that no test covers at another arithmetic.

Definition in file sylvester.h.