Skip to contents

The procedure computes "grammians" of a statespace realization, which may e.g. be used for balancing the statespace realization.

Usage

grammians(
  obj,
  which = c("lyapunov", "minimum phase", "ctr", "obs", "obs_inv", "ctr_inv")
)

Arguments

obj

(stsp object) rational matrix in statespace form.

which

(character string) specifies the type of Grammian(s) to be computed.See below for more details.

Value

Either the selected Grammian (if which is one of 'ctr', 'obs', 'ctr_inv', 'obs_inv') or a list with two components P and Q (for the case which = 'lyapunov'

or which = 'miniumum phase').

Details

The controllability Grammian \(P\) of a (stable) statespace realization $$K(z) = C(Iz^{-1} - A)^{-1}B + D$$ is the solution of the Lyapunov equation \(P = APA' + BB'\). The observability Grammian is the solution of the Lyapunov equation \(Q = A'QA + C'C\). If the statespace realization is stable (the moduli of the eigenvalues of A are less than one) then \(P,Q\) are positive semidefinite and \(P\) is non singular if and only if the statespace realization is controllable and \(Q\) is non singular if and only if the statespace realization is observable. Hence the grammians may also be used to check whether the statespace realization is minimal (controllable and observable).

If the rational matrix is (strictly) minimum phase (i.e. \(K(z)\) is a square, invertible matrix and the eigenvalues of the matrix \((A - BD^{-1}C)\) have moduli less than one) then we may also compute the controllability and the observability Grammian of the statespace realization $$K^{-1}(z) = -D^{-1}C (Iz^{-1} - (A - BD^{-1}C))^{-1}BD^{-1} + D^{-1}.$$ of the inverse matrix \(K^{-1}(z)\). These grammians have a similar interpretation.

The above described grammians may be selected by setting the parameter which to 'ctr', 'obs', 'ctr_in' or 'obs_inv' respectively.

For balancing a statespace realization one needs a suitable pair of grammians. Two popular choices have been implemented: For which = 'lyapunov' the procedure returns the controllability and the observability Grammian and for which = 'minimum phase' the controllability matrix of the system and the observability Grammian of the inverse system are returned.

The procedure throws an error if the state space realization is not stable, respectively not minimum phase.

Examples

# create a random, (3 by 2) rational matrix, 
# with a stable and minimum phase statespüace realization
obj = test_stsp(dim = c(3,2), s = 5, bpoles = 1, bzeroes = 1)
gr = grammians(obj, which = 'lyapunov')
gr
#> $P
#>             [,1]       [,2]      [,3]       [,4]        [,5]
#> [1,]  1.75854575  0.5888279 -1.089629  1.2925305  0.03385251
#> [2,]  0.58882791  6.6838386 -1.472853  3.2823785 -2.95932269
#> [3,] -1.08962856 -1.4728532  2.516513 -1.0414025  2.17289281
#> [4,]  1.29253046  3.2823785 -1.041403  3.0760257 -0.75763932
#> [5,]  0.03385251 -2.9593227  2.172893 -0.7576393  3.33231347
#> 
#> $Q
#>             [,1]      [,2]       [,3]        [,4]      [,5]
#> [1,]  1.65541510 0.3891806 -1.4222349  0.06955503  1.880569
#> [2,]  0.38918057 2.2877251  0.1413221  1.29137034  2.870756
#> [3,] -1.42223495 0.1413221 11.2081417 -1.00520715 -3.134027
#> [4,]  0.06955503 1.2913703 -1.0052072  1.95406403  2.624635
#> [5,]  1.88056874 2.8707555 -3.1340267  2.62463485  6.654324
#> 

# we could also compute these grammians seperately 
all.equal(gr$P, grammians(obj,'ctr'))
#> [1] TRUE
all.equal(gr$Q, grammians(obj,'obs'))
#> [1] TRUE

# create a random (3 by 3) rational matrix, 
# with a stable and minimum phase statespüace realization
# Note: for the choice "minimum phase" the rational matrix 
# must be square and invertible.
obj = test_stsp(dim = c(3,3), s = 5, bpoles = 1, bzeroes = 1)
gr = grammians(obj, which = 'minimum phase')
gr
#> $P
#>             [,1]        [,2]       [,3]        [,4]       [,5]
#> [1,]  0.60731526  0.07090535 -0.2155224 -0.43699796 -0.3043777
#> [2,]  0.07090535  0.34603138  0.2138768 -0.03911016  0.3622185
#> [3,] -0.21552245  0.21387680  0.6117186  0.13560943  0.3866763
#> [4,] -0.43699796 -0.03911016  0.1356094  1.18824605  0.1541981
#> [5,] -0.30437773  0.36221851  0.3866763  0.15419809  0.7541223
#> 
#> $Q
#>             [,1]        [,2]        [,3]        [,4]       [,5]
#> [1,]  0.80024906 -0.03445707  0.04089277 -0.06332531 -0.4242316
#> [2,] -0.03445707  3.17234195  1.65214181  0.07529511 -0.3142350
#> [3,]  0.04089277  1.65214181  2.12236750  0.81670407 -0.4835048
#> [4,] -0.06332531  0.07529511  0.81670407  0.68035004 -0.1852334
#> [5,] -0.42423163 -0.31423495 -0.48350482 -0.18523338  1.1096180
#> 

# we could also compute these grammians seperately 
all.equal(gr$P, grammians(obj,'ctr'))
#> [1] TRUE
all.equal(gr$Q, grammians(obj,'obs_inv'))
#> [1] TRUE