1% moms = MomentsFromME(alpha, A, K, prec)
3% Returns the first K moments of a matrix-exponential
8% alpha : vector, shape (1,M)
9% The initial vector of the matrix-exponential
11% A : matrix, shape (M,M)
12% The matrix parameter of the matrix-exponential
15% Number of moments to compute. If K=0, 2*M-1 moments
16% are computed. The
default value
is K=0.
17% prec : double, optional
18% Numerical precision
for checking the input.
19% The
default value
is 1e-14.
23% moms : row vector of doubles
24% The vector of moments.
27function moms = MomentsFromME (alpha, A, K)
29 global BuToolsCheckInput;
30 if isempty(BuToolsCheckInput)
31 BuToolsCheckInput =
true;
34 if BuToolsCheckInput && ~CheckMERepresentation(alpha, A)
35 error(
'MomentsFromME: Input isn''t a valid ME representation!');
38 if ~exist(
'K',
'var') || K==0
39 K = 2*length(alpha)-1;
45 moms(i) = factorial(i) * sum(alpha*iA^i);