Upgrade Objects to Common Class
upgrade_objects.Rd
Used in cbind
,
rbind
,
ratm_mult
,
and Ops.ratm
to make operations on different subclasses of the (super-) class ratm
possible.
Arguments
- force
Default set to TRUE. If FALSE, then objects are also coerced when only one object is supplied. Option FALSE is used in bind methods
- ...
Arbitrary number of objects with superclass
ratm
Details
Constant matrices are always upgraded to polm
,
and lmfd
and rmfd
are always upgraded to stsp
if two ratm
objects are involved.
Therefore, most operations are performed in the state space setting.
Depending on the highest "grade" of any object involved in the operation, the lower ranked object is upgraded to the highest one.
The following ranks are assigned to the ratm
objects:
Laurent polynomials lpolm
have a special place because they are detached from/unconnected to elements lmfd
, rmfd
, stsp
, pseries
, zvalues
.
Operations with lpolm
are only possible with polm
objects (and those which can be coerced to polm
).
Operations which are not defined are
Examples
p = test_polm(degree = 2)
lp = test_lpolm(degree_max = 1, degree_min = -1)
l = test_lmfd()
r = test_lmfd()
ss = test_stsp(s = 1)
ps = pseries(ss)
zv = zvalues(ss)
# Only one argument
rationalmatrices:::upgrade_objects(force = TRUE, l)
#> [[1]]
#> statespace realization [1,1] with s = 1 states
#> s[1] u[1]
#> s[1] 1.181889 4.578742
#> x[1] 1.000000 1.856831
#>
rationalmatrices:::upgrade_objects(force = FALSE, l)
#> [[1]]
#> ( 1 x 1 ) left matrix fraction description a^(-1)(z) b(z) with degrees (p = 1, q = 1)
#> left factor a(z):
#> z^0 [,1] z^1 [,1]
#> [1,] 1 -1.181889
#> right factor b(z):
#> z^0 [,1] z^1 [,1]
#> [1,] 1.856831 2.384173
#>
# Upgrade poly to rmfd
rationalmatrices:::upgrade_objects(force = TRUE, p, r)
#> [[1]]
#> statespace realization [1,1] with s = 2 states
#> s[1] s[2] u[1]
#> s[1] 0 0 1
#> s[2] 1 0 0
#> x[1] 111 112 110
#>
#> [[2]]
#> statespace realization [1,1] with s = 1 states
#> s[1] u[1]
#> s[1] -0.4218751 0.1254212
#> x[1] 1.0000000 -2.0095552
#>
rationalmatrices:::upgrade_objects(force = TRUE, l, ps)
#> [[1]]
#> ( 1 x 1 ) impulse response with maximum lag = 5
#> lag=0 [,1] lag=1 [,1] lag=2 [,1] lag=3 [,1] lag=4 [,1] lag=5 [,1]
#> [1,] 1.856831 4.578742 5.411566 6.395872 7.559212 8.934152
#>
#> [[2]]
#> ( 1 x 1 ) impulse response with maximum lag = 5
#> lag=0 [,1] lag=1 [,1] lag=2 [,1] lag=3 [,1] lag=4 [,1]
#> [1,] 1 -0.3728132 0.0009012476 -2.178698e-06 5.266837e-09
#> lag=5 [,1]
#> [1,] -1.273218e-11
#>