1function R = map_compute_R(C, D, mu)
2% MAP_COMPUTE_R Compute rate matrix R
for MAP/M/1 queue
4% R = MAP_COMPUTE_R(C, D, mu) computes the matrix R, which
is the minimal
5% nonnegative solution of the matrix equation:
6% D + R(C - mu*I) + mu*R^2 = O
8% This matrix
is used in the analysis of MAP/M/1 queues based on
9% quasi-birth-death processes.
12% C - M x M matrix governing MAP transitions without arrivals
13% D - M x M matrix governing MAP transitions with arrivals
14% mu - Service rate (scalar)
17% R - M x M rate matrix (minimal nonnegative solution)
20% Masuyama, H., & Takine, T. (2003). Sojourn time distribution in a
21% MAP/M/1 processor-sharing queue. Operations Research Letters, 31(6),
24% See also: MAP_M1PS_SOJOURN, MAP_M1PS_H_RECURSIVE
26% Copyright (c) 2012-2025, Imperial College London
32% Use iterative method to solve
for R: R = -D(C - mu*I + mu*R)^{-1}
40 % R_{k+1} = -D * inv(C - mu*I + mu*R_k)
41 R = -D / (C - mu*I + mu*R);
44 if norm(R - R_old, inf) < tol
50 warning(
'MAP_COMPUTE_R:NoConvergence', ...
51 'R computation did not converge within %d iterations', max_iter);
54% Ensure non-negativity (numerical errors might produce small negative values)