degree {polyMatrix} | R Documentation |
Gets the maximum degree of polynomial objects
Description
Returns the maximum degree as an integer number.
Usage
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)
-
numeric
: a scalar argument always has zero degree -
matrix
: a numerical matrix always has zero degree -
polynomial
: the degree of a polynomial -
polyMatrix
: the degree of a polynomial matrix is the highest degree of its elements
Examples
# 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
[Package polyMatrix version 0.9.16 Index]