polyMatrix-class: A class to represent a matrix of polynomials

Description Usage Arguments Methods (by generic) Slots Examples

Description

A class to represent a matrix of polynomials

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
## S4 method for signature 'polyMatrix,numeric'
x[[i]]

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

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

## S4 method for signature 'polynomial'
nrow(x)

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

## S4 method for signature 'polynomial'
ncol(x)

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

## S4 method for signature 'polyMatrix'
predict(object, newdata)

## S4 method for signature 'polyMatrix'
round(x, digits = 0)

## S4 method for signature 'polyMatrix'
show(object)

## S4 method for signature 'polyMatrix,polyMatrix'
e1 == e2

## S4 method for signature 'polyMatrix,polynomial'
e1 == e2

## S4 method for signature 'polyMatrix,matrix'
e1 == e2

## S4 method for signature 'polyMatrix,numeric'
e1 == e2

## S4 method for signature 'ANY,polyMatrix'
e1 == e2

## S4 method for signature 'polyMatrix,ANY'
e1 != e2

## S4 method for signature 'ANY,polyMatrix'
e1 != e2

Arguments

x

a matrix object

i

the degree of the matrix of coefficient to be extracted

object

an R object

newdata

the value to be evaluated

digits

an integer indicating the number of decimal places (round) or significant digits (signif) to be used

e1

an left operand

e2

an right operand

Methods (by generic)

Slots

coef

A matrix of coefficients which are joined into one matrix from lower degree to higher

ncol

The actual number of columns in the polynomial matrix

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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# create a new polynomial matrix by parsing strings
pm <- parse.polyMatrix(
     "x; 1 + x^2; 3 x - x^2",
     "1; 1 + x^3; - x + x^3"
)

# get coefficient matrix for degree 0
pm[[0]]
##      [,1] [,2] [,3]
## [1,]    0    1    0
## [2 ]    1    1    0
# get coefficient matrix for degree 1
pm[[1]]
##      [,1] [,2] [,3]
## [1,]    1    0    3
## [2 ]    0    0   -1


# dimensions
nrow(pm) ## 2


ncol(pm) ## 3


dim(pm) ## [1] 2 3


# round
round(parse.polyMatrix(
  "      1.0001 - x,            1 - x^2, 1 + 2.0003*x + x^2",
  "0.0001 + x - x^2, 1 + x + 0.0001 x^2, 1 - 2*x + x^2"
))
##           [,1]      [,2]           [,3]
## [1,]     1 - x   1 - x^2   1 + 2x + x^2
## [2,]   x - x^2     1 + x   1 - 2x + x^2


# print out a polynomial matrix
show(parse.polyMatrix(
  "      1.0001 - x,          1 - x^2, 1 + 2.0003*x + x^2",
  "0.0001 + x - x^2,            1 + x, 1 - 2*x + x^2",
  "        12.3 x^3,  2 + 3.5 x + x^4, -0.7 + 1.6e-3 x^3"
))
##                   [,1]             [,2]                [,3]
## [1,]        1.0001 - x          1 - x^2   1 + 2.0003x + x^2
## [2,]   1e-04 + x - x^2            1 + x        1 - 2x + x^2
## [3,]           12.3x^3   2 + 3.5x + x^4    -0.7 + 0.0016x^3

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