# NOT RUN {
# numerical matrices
m <- matrix(1:12, 3, 4)
## [,1] [,2] [,3] [,4]
## [1,] 1 4 7 10
## [2,] 2 5 8 11
## [3,] 3 6 9 12
tr(m) ## 15
# polynomial matrix
pm <- parse.polyMatrix(
"-3 + x^2, 2 + 4 x, -x^2",
" 1, 2, 3 + x",
" 2*x, 0, 2 - 3 x"
)
tr(pm) ## 1 - 3*x + x^2
# }
Run the code above in your browser using DataLab