Skip to contents

The subsetting operation x[,] for rational matrices works analogously to the subsetting of ordinary matrices. However, this operator is only partly implemented for lmfd and lmfd objects. See the details below.
The $ operator may be used to extract the polynomial factors of a left/right matrix fraction description (lmfd, rmfd object). Furthermore one may retrieve the parameter matrices \(A,B,C,D\) of a state space representation (stsp object). For an zvalues object, we may access the complex numbers at which the rational matrix has been evaluated.

Usage

# S3 method for polm
[(x, i, j)

# S3 method for lpolm
[(x, i, j)

# S3 method for lmfd
[(x, i, j)

# S3 method for rmfd
[(x, i, j)

# S3 method for stsp
[(x, i, j)

# S3 method for pseries
[(x, i, j)

# S3 method for zvalues
[(x, i, j)

# S3 method for lmfd
$(x, name)

# S3 method for rmfd
$(x, name)

# S3 method for stsp
$(x, name)

# S3 method for zvalues
$(x, name)

Arguments

x

a rational matrix, i.e. a polm, lpolm, lmfd, rmfd, stsp, pseries or zvalues object.

i, j

indices (integer or boolean vector)

name

character: A,B,C,D for stsp objects, a,b for lmfd objects, c,d for rmfd objects and z,f for zvalues objects.

Value

The subsetting operation x[i,j] returns a rational matrix of the same class as the input x. The mode of the output of the $ operator depends on which "component" of the rational matrix is extracted. See the details above.

Details

  • x[] or x[,] simply return the original object.

  • x[i] returns a "vector", i.e. an \((s,1)\) dimensional matrix.

  • x[i,], x[,j] or x[i,j] return a rational matrix with rows selected by i and columns selected by j.

  • Note: for lmfd objects (rmfd objects) only extraction of columns (respectively rows) is implemented. Therefore, e.g. x[i,] throws an error if x is an lmfd object.

  • Note that "named" arguments are not supported (in order to simplify the coding).

  • In order to have a finer control, one may e.g. use unclass(x)[,,].

  • x$a, x$b returns the left, respectively right factor of an LMFD \(x(z) = a^{-1}(z)b(z)\). (x is an lmfd object).

  • x$c, x$d returns the right, respectively left factor of an RMFD \(x(z) = d(z)c^{-1}(z)\). (x is an rmfd object.)

  • x$A, x$B, x$C, x$D return the parameter matrices of the statespace realization \(x(z) = D + z (I- Az)^{-1}B\). (x is an stsp object.)

  • If x is an zvalues object, then x$z returns the vector of complex points at which the rational matrix \(x\) has been evaluated. Furthermore x$f gives the corresponding "frequencies", i.e. x$f = -Arg(x$z)/(2*pi).

Examples

# polynomial matrices 
a = test_polm(dim = c(3,2), degree = 1)
a[]          # returns a
#> ( 3 x 2 ) matrix polynomial with degree <= 1 
#>      z^0 [,1]  [,2] z^1 [,1]  [,2]
#> [1,]      110   120      111   121
#> [2,]      210   220      211   221
#> [3,]      310   320      311   321
a[,]         # returns a
#> ( 3 x 2 ) matrix polynomial with degree <= 1 
#>      z^0 [,1]  [,2] z^1 [,1]  [,2]
#> [1,]      110   120      111   121
#> [2,]      210   220      211   221
#> [3,]      310   320      311   321
a[c(1,3,6)]  # returns a "vector" with the (1,1), (3,1) and (3,2) element of a
#> ( 3 x 1 ) matrix polynomial with degree <= 1 
#>      z^0 [,1] z^1 [,1]
#> [1,]      110      111
#> [2,]      310      311
#> [3,]      320      321
a[1,]        # returns the first row of a 
#> ( 1 x 2 ) matrix polynomial with degree <= 1 
#>      z^0 [,1]  [,2] z^1 [,1]  [,2]
#> [1,]      110   120      111   121
a[,2]        # returns the second column of a 
#> ( 3 x 1 ) matrix polynomial with degree <= 1 
#>      z^0 [,1] z^1 [,1]
#> [1,]      120      121
#> [2,]      220      221
#> [3,]      320      321
a[c(TRUE,FALSE,TRUE),c(FALSE, TRUE)] # returns a 2 by 1 matrix 
#> ( 2 x 1 ) matrix polynomial with degree <= 1 
#>      z^0 [,1] z^1 [,1]
#> [1,]      120      121
#> [2,]      320      321
a[c(1,1),c(2,1)] # returns a 2 by 2 matrix 
#> ( 2 x 2 ) matrix polynomial with degree <= 1 
#>      z^0 [,1]  [,2] z^1 [,1]  [,2]
#> [1,]      120   110      121   111
#> [2,]      120   110      121   111
# check with pseries/zvalues
all.equal(pseries(a[c(1,1),c(2,1)]), pseries(a)[c(1,1),c(2,1)])
#> [1] TRUE
all.equal(zvalues(a[c(1,1),c(2,1)]), zvalues(a)[c(1,1),c(2,1)])
#> [1] TRUE

if (FALSE) {
a[i=1, j=2] # throws an error, since "named" arguments are not allowed.
}

# the subsetting operator [,] is only implemented for "lmfd" columns
(l = test_lmfd(dim = c(2,2), degrees = c(1,1)))
#> ( 2 x 2 ) left matrix fraction description a^(-1)(z) b(z) with degrees (p = 1, q = 1)
#> left factor a(z):
#>      z^0 [,1]  [,2]    z^1 [,1]       [,2]
#> [1,]        1     0 -0.01210036 -0.3491946
#> [2,]        0     1  1.50471264 -0.5306695
#> right factor b(z):
#>        z^0 [,1]       [,2]    z^1 [,1]       [,2]
#> [1,]  0.6701444 -1.2308967  0.05706774 -0.6674941
#> [2,] -0.8278202  0.1932192 -0.05043792  1.1569349
l[,1]
#> ( 2 x 1 ) left matrix fraction description a^(-1)(z) b(z) with degrees (p = 1, q = 1)
#> left factor a(z):
#>      z^0 [,1]  [,2]    z^1 [,1]       [,2]
#> [1,]        1     0 -0.01210036 -0.3491946
#> [2,]        0     1  1.50471264 -0.5306695
#> right factor b(z):
#>        z^0 [,1]    z^1 [,1]
#> [1,]  0.6701444  0.05706774
#> [2,] -0.8278202 -0.05043792

# the subsetting operator [,] is only implemented for "rmfd" rows
(r = test_rmfd(dim = c(2,2), degrees = c(1,1)))
#> ( 2 x 2 ) right matrix fraction description d(z) c^(-1)(z) with degrees deg(c(z)) = p = 1, deg(d(z)) = q = 1
#> left factor d(z):
#>        z^0 [,1]       [,2]   z^1 [,1]       [,2]
#> [1,] -0.3348552 -1.7740722 -0.2626869 0.02955932
#> [2,] -0.3925517  0.2818615  0.3567823 1.60352699
#> right factor c(z):
#>      z^0 [,1]  [,2]   z^1 [,1]       [,2]
#> [1,]        1     0 -0.6754928 -0.4743796
#> [2,]        0     1  1.9233477 -0.6804595
r[1,]
#> ( 1 x 2 ) right matrix fraction description d(z) c^(-1)(z) with degrees deg(c(z)) = p = 1, deg(d(z)) = q = 1
#> left factor d(z):
#>        z^0 [,1]      [,2]   z^1 [,1]       [,2]
#> [1,] -0.3348552 -1.774072 -0.2626869 0.02955932
#> right factor c(z):
#>      z^0 [,1]  [,2]   z^1 [,1]       [,2]
#> [1,]        1     0 -0.6754928 -0.4743796
#> [2,]        0     1  1.9233477 -0.6804595