Learn R Programming

polyMatrix (version 0.9.16)

zero.round: Rounds objects to zero if there is too small

Description

Rounds objects to zero if there is too small

Usage

zero.round(x, eps = ZERO_EPS)

# S4 method for polynomial zero.round(x, eps = ZERO_EPS)

# S4 method for polyMatrix zero.round(x, eps = ZERO_EPS)

Arguments

x

an R object

eps

Minimal numerical value which will not be treated as zero

Methods (by class)

  • polynomial: rounding of a polynomial means rounding of each coefficient

  • polyMatrix: rounding of a polynomial matrix

Details

By befault eps = {r} ZERO_EPS

See Also

is.zero()

Examples

Run this code
# NOT RUN {
# numerical
zero.round(1)  ## 1
zero.round(0)  ## 0
zero.round(0.1, eps=0.5) ## 0
zero.round(c(1, 0, .01, 1e-10)) ##  1.00 0.00 0.01 0.00


# polynomials
zero.round(parse.polynomial("0.1 + x + 1e-7 x^2")) ## 0.1 + x
zero.round(parse.polynomial("0.1 + x + 1e-7 x^2"), eps=0.5) ## x


# polynomial matrix
zero.round(parse.polyMatrix(
  "1 + 0.1 x, 10 + x + 3e-8 x^2, 1e-8",
  "0.1 + x^2,     .1 + 1e-8 x^4, 1e-8 x^5"
))
##             [,1]     [,2]   [,3]
## [1,]    1 + 0.1x   10 + x      0
## [2,]   0.1 + x^2      0.1      0

zero.round(parse.polyMatrix(
  "1 + 0.1 x, 10 + x + 3e-8 x^2, 1e-8",
  "0.1 + x^2,     .1 + 1e-8 x^4, 1e-8 x^5"
), eps=0.5)
##        [,1]     [,2]   [,3]
## [1,]      1   10 + x      0
## [2,]    x^2        0      0

# }

Run the code above in your browser using DataLab