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

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

Description

Rounds objects to zero if there is too small

Usage

1
2
3
4
5
6
7
zero.round(x, eps = ZERO_EPS)

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

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

Arguments

x

an R object

eps

Minimal numerical value which will not be treated as zero

Details

By befault eps = {r} ZERO_EPS

Methods (by class)

See Also

is.zero()

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
# 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

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