# NOT RUN {
# numericals and numerical matrices
diag(matrix(1:12, 3, 4)) ## 1 5 8
diag(9, 2, 2)
## [,1] [,2]
## [1,] 9 0
## [2,] 0 9
# polynomial
diag(parse.polynomial("1+x+3x^2"), 2, 3)
## [,1] [,2] [,3]
## [1,] 1 + x + 3x^2 0 0
## [2,] 0 1 + x + 3x^2 0
# polynomial matrix
diag(parse.polyMatrix(
"-3 + x^2, 2 + 4 x, -x^2",
" 1, 2, 3 + x",
" 2x, 0, 2 - 3x"
))
## [,1] [,2] [,3]
## [1,] -3 + x^2 2 2 - 3x
# }
Run the code above in your browser using DataLab