sorted_incidence_matrix(sys) is the incidence matrix (equations by
unknowns, 1 where the unknown occurs in the equation) of a system
returned by mtkcompile(), with the columns ordered by the strongly
connected components of its schedule. but_ordered_incidence(ts)
computes the block upper triangular ordering of a TearingState() and
returns the ordered incidence matrix and the block boundaries.
highest_order_variable_mask(ts) and lowest_order_variable_mask(ts)
return predicates on variable indices that select the variables without a
derivative, or that are not a derivative, in the state.
Usage
sorted_incidence_matrix(sys)
highest_order_variable_mask(ts)
lowest_order_variable_mask(ts)
but_ordered_incidence(ts, varmask = highest_order_variable_mask(ts))Arguments
- sys
A system returned by
mtkcompile().- ts
A
TearingState.- varmask
A predicate on variable indices selecting the variables that take part in the ordering.
Value
A 0/1 matrix; but_ordered_incidence() returns a list with the
matrix and the block boundaries; the masks are functions.
Examples
t <- t_nounits; D <- D_nounits
variables("x(t)", "y(t)"); parameters("k")
eqs <- list(D(x) ~ -k * y, D(y) ~ x)
sorted_incidence_matrix(mtkcompile(System(eqs, t, name = "sys")))
#> [,1] [,2] [,3] [,4]
#> [1,] 0 1 0 1
#> [2,] 1 0 1 0
ts <- TearingState(System(eqs, t, name = "sys"))
highest_order_variable_mask(ts)(seq_along(ts$fullvars))
#> [1] TRUE TRUE FALSE FALSE
but_ordered_incidence(ts)
#> [[1]]
#> [,1] [,2]
#> [1,] 1 0
#> [2,] 0 1
#>
#> [[2]]
#> [1] 1 2 3
#>