Learn R Programming

polyMatrix (version 0.9.16)

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

Description

A class to represent a matrix of polynomials

Usage

# S4 method for polyMatrix,numeric
[[(x, i)

# S4 method for polyMatrix det(x)

# S4 method for polyMatrix nrow(x)

# S4 method for polynomial nrow(x)

# S4 method for polyMatrix ncol(x)

# S4 method for polynomial ncol(x)

# S4 method for polyMatrix dim(x)

# S4 method for polyMatrix predict(object, newdata)

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

# S4 method for polyMatrix show(object)

# S4 method for polyMatrix,polyMatrix ==(e1, e2)

# S4 method for polyMatrix,polynomial ==(e1, e2)

# S4 method for polyMatrix,matrix ==(e1, e2)

# S4 method for polyMatrix,numeric ==(e1, e2)

# S4 method for ANY,polyMatrix ==(e1, e2)

# S4 method for polyMatrix,ANY !=(e1, e2)

# S4 method for 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)

  • [[: get coefficient matrix by degree

  • det: determinant of a polynomial matrix

  • nrow: the number of rows of a polynomial matrix

  • nrow: a polynomial has only one row

  • ncol: the number of columns of a polynomial matrix

  • ncol: a polynomial has only one column

  • dim: the dimension of a polynomial matrix

  • predict: the value of a polynomial matrix in a point

  • round: rounding of a polynomial matrix is rounding of polynomial coefficients

  • show: prints out a text representation of a polynomial matrix

  • ==: equal operator for two polinomial matrices, result is a boolean matrix

  • ==: equal operator for polinomail matrix and polinomail, result is a matrix

  • ==: equal operator for polinomial and numerical matrices

  • ==: equal operator for polinomial matrix and number, result is a matrix

  • ==: equal operator for aby object and polinomial matrix

  • !=: not equal operator

  • !=: not equal operator

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

Run this code
# NOT RUN {
# 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

# }

Run the code above in your browser using DataLab