diag: Polynomial matrix Diagonals Extract or construct a diagonal...

Description Usage Arguments Details Methods (by class) See Also Examples

Description

Polynomial matrix Diagonals Extract or construct a diagonal polynomial matrix.

Usage

1
2
3
4
5
6
7
diag(x = 1, nrow, ncol, names = TRUE)

## S4 method for signature 'polynomial'
diag(x, nrow, ncol)

## S4 method for signature 'polyMatrix'
diag(x)

Arguments

x

a polynomial matrix, or a polynomial, or an R object

nrow, ncol

optional dimensions for the result when x is not a matrix

names

not used for polynomial matrices

Details

In case of polynomial objects, diag has 2 distinct usage:

For polynomial, either nrow or ncol must be provided.

Methods (by class)

See Also

Base base::diag() for numericals and numerical matrices

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 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

polyMatrix documentation built on July 18, 2021, 5:06 p.m.