degree: Gets the maximum degree of polynomial objects

Description Usage Arguments Details Value Methods (by class) Examples

Description

Returns the maximum degree as an integer number.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
degree(x)

## S4 method for signature 'numeric'
degree(x)

## S4 method for signature 'matrix'
degree(x)

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

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

Arguments

x

an R objects

Details

By default, this function raises error for unknown type of object.

A numerical scalar can be treated as a polynomial with zero degree.

A numerical matrix has zero degree as each of its items has zero degree as well.

For polynomials this function returns the highest degree of its terms with non-zero coefficient.

Value

The value is an integer number which can be different from zero only for polynomial objects.

Methods (by class)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# numerical
degree(1)  ## 0


# numerical matrix
degree(matrix(1:6, 3, 2)) ## 0


# polinomial
degree(parse.polynomial("1")) ## 0
degree(parse.polynomial("1 + x")) ## 1
degree(parse.polynomial("1 + x^3")) ## 3


# polynomial matrices
degree(parse.polyMatrix(
   "x; x^2 + 1",
   "0; 2x"))
## 2

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