Title: | Infrastructure for Manipulation Polynomial Matrices |
---|---|
Description: | Implementation of class "polyMatrix" for storing a matrix of polynomials and implements basic matrix operations; including a determinant and characteristic polynomial. It is based on the package 'polynom' and uses a lot of its methods to implement matrix operations. This package includes 3 methods of triangularization of polynomial matrices: Extended Euclidean algorithm which is most classical but numerically unstable; Sylvester algorithm based on LQ decomposition; Interpolation algorithm is based on LQ decomposition and Newton interpolation. Both methods are described in D. Henrion & M. Sebek, Reliable numerical methods for polynomial matrix triangularization, IEEE Transactions on Automatic Control (Volume 44, Issue 3, Mar 1999, Pages 497-508) <doi:10.1109/9.751344> and in Salah Labhalla, Henri Lombardi & Roger Marlin, Algorithmes de calcule de la reduction de Hermite d'une matrice a coefficients polynomeaux, Theoretical Computer Science (Volume 161, Issue 1-2, July 1996, Pages 69-92) <doi:10.1016/0304-3975(95)00090-9>. |
Authors: | Tamas Prohle [aut], Peter Prohle [aut], Nikolai Ryzhkov [aut, cre], Ildiko Laszlo [aut] , Ulas Onat Alakent [ctb] |
Maintainer: | Nikolai Ryzhkov <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.9.11 |
Built: | 2024-10-30 02:59:35 UTC |
Source: | https://github.com/namezys/polymatrix |
The adjugate or classical adjoint of a square matrix is the transpose of its cofactor matrix. It is also occasionally known as adjunct matrix,[ though this nomenclature appears to have decreased in usage.
adjoint(x) ## S4 method for signature 'polyMatrix' adjoint(x)
adjoint(x) ## S4 method for signature 'polyMatrix' adjoint(x)
x |
an matrix |
polyMatrix
: adjugate of polynomial matrix
Combine polynial matrices by rows or coluns
cbind(..., deparse.level = 1) rbind(..., deparse.level = 1)
cbind(..., deparse.level = 1) rbind(..., deparse.level = 1)
... |
(generalzed) vectors or mmatrices. If any of objects are polynomail matrix |
deparse.level |
details in base function, polynomial matrices doesn't use it |
if at least one argument is a polynomail matrix,
the result will be combined polynomial matrix.
Overwise, base package implementatioon base::cbind()
or base::rbind()
will be called.
rbind
: row based bind
Characteristic polynomial of matrix
charpolynom(x) ## S4 method for signature 'matrix' charpolynom(x) ## S4 method for signature 'polynomial' charpolynom(x) ## S4 method for signature 'polyMatrix' charpolynom(x) ## S4 method for signature 'polyMatrixCharPolynomial,ANY' x[[i]] ## S4 method for signature 'polyMatrixCharPolynomial' degree(x) ## S4 method for signature 'polyMatrixCharPolynomial' predict(object, newdata) ## S4 method for signature 'polyMatrixCharPolynomial' show(object)
charpolynom(x) ## S4 method for signature 'matrix' charpolynom(x) ## S4 method for signature 'polynomial' charpolynom(x) ## S4 method for signature 'polyMatrix' charpolynom(x) ## S4 method for signature 'polyMatrixCharPolynomial,ANY' x[[i]] ## S4 method for signature 'polyMatrixCharPolynomial' degree(x) ## S4 method for signature 'polyMatrixCharPolynomial' predict(object, newdata) ## S4 method for signature 'polyMatrixCharPolynomial' show(object)
x |
an matrix |
i |
the degree to extract polinomial coefficient |
object |
an R object |
newdata |
the value to evaluate |
The characteristic polynom of a polynomial matrix is a polynom with polynomial coefficients.
When the input is a numerical matrix of matrix
class
then the value is a polynomial
object.
When the input is a polyMatrix
object
then a value is polyMatrixCharClass
class object,
matrix
: for numerical matrix it is a polynomial with numerical coefficients
polynomial
: for polynomial it treats as a matrix 1x1
polyMatrix
: for polynomial matrix it has polynomial coefficients
x = polyMatrixCharPolynomial,i = ANY
: get polynomial coefficient of characteristic
polyMatrixCharPolynomial
: the degree of char polynomail of polynomial matrix
polyMatrixCharPolynomial
: value of char polynomail in polynomial point
polyMatrixCharPolynomial
: prints out a text representation of a characteristic polinomial of
polinomial matrix
polyMatrixCharClass
# numerical matrices m <- matrix(c(2, 1, -1, 0), 2, 2, byrow=TRUE) charpolynom(m)
# numerical matrices m <- matrix(c(2, 1, -1, 0), 2, 2, byrow=TRUE) charpolynom(m)
Cofactor of matrix
cofactor(x, r, c)
cofactor(x, r, c)
x |
an matrix |
r , c
|
the row and column |
cofactor which is number or polynomial
Returns the maximum degree as an integer number.
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)
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)
x |
an R objects |
By default, this function raises error for unknown type of object.
A numerical scalar has 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.
The value is an integer number which can be different from zero only for polynomial objects.
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
# 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
# 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
Polynomial matrix Diagonals Extract or construct a diagonal polynomial matrix.
diag(x = 1, nrow, ncol, names = TRUE) ## S4 method for signature 'polynomial' diag(x, nrow, ncol) ## S4 method for signature 'polyMatrix' diag(x)
diag(x = 1, nrow, ncol, names = TRUE) ## S4 method for signature 'polynomial' diag(x, nrow, ncol) ## S4 method for signature 'polyMatrix' diag(x)
x |
a polynomial matrix, or a polynomial, or an R object |
nrow , ncol
|
optional dimensions for the result when x is not a matrix. |
names |
not usedd |
In case of polynomail objets, diag
has 2 distinct usage:
x
is a polynomial, it returns a polynomial matrix the given diagonal
and zero off-diagonal entries.
x
is a polynomial matrix, it returns a vector as a polynomial matrix of
diagonal elements
For polynomial, either nrow
or ncol
must be provided.
polynomial
: for a polynomial, returns polynomial matrix with given diagonal
polyMatrix
: for a polynomial matrix extract diagonal
For polynomial matrix, neither nrow
and ncol
can't be provided.
Base base::diag()
for numericals and numerical matrices
# numericals and numerical matrix diag(matrix(1:12, 3, 4)) ## 1 5 8 diag(9, 2, 2) ## [,1] [,2] ## [1,] 9 0 ## [2,] 0 9 # polynomial diag(parse.polynomial("1+x+3x^2"), 2, 3) ## [,1] [,2] [,3] ## [1,] 1 + x + 3x^2 0 0 ## [2,] 0 1 + x + 3x^2 0 # polynomial matrix diag(parse.polyMatrix( "-3 + x^2, 2 + 4 x, -x^2", " 1, 2, 3 + x", " 2x, 0, 2 - 3x" )) ## [,1] [,2] [,3] ## [1,] -3 + x^2 2 2 - 3x
# numericals and numerical matrix diag(matrix(1:12, 3, 4)) ## 1 5 8 diag(9, 2, 2) ## [,1] [,2] ## [1,] 9 0 ## [2,] 0 9 # polynomial diag(parse.polynomial("1+x+3x^2"), 2, 3) ## [,1] [,2] [,3] ## [1,] 1 + x + 3x^2 0 0 ## [2,] 0 1 + x + 3x^2 0 # polynomial matrix diag(parse.polyMatrix( "-3 + x^2, 2 + 4 x, -x^2", " 1, 2, 3 + x", " 2x, 0, 2 - 3x" )) ## [,1] [,2] [,3] ## [1,] -3 + x^2 2 2 - 3x
The greatest common divisor of polynomials or polynomial matrices.
GCD(...) ## S4 method for signature 'polyMatrix' GCD(...)
GCD(...) ## S4 method for signature 'polyMatrix' GCD(...)
... |
an list of polynomial objects |
polyMatrix
: the greatest common divisor of all elements of the polynomial matrice
polynomial implementation polynom::GCD()
and LCM()
# GCD of polynomial matrix GCD(parse.polyMatrix( " 1 - x, 1 - x^2, 1 + 2*x + x^2", "x - x^2, 1 + x, 1 - 2*x + x^2" )) ## 1
# GCD of polynomial matrix GCD(parse.polyMatrix( " 1 - x, 1 - x^2, 1 + 2*x + x^2", "x - x^2, 1 + x, 1 - 2*x + x^2" )) ## 1
During inversion we will try to round to zero
inv(x, eps = ZERO_EPS)
inv(x, eps = ZERO_EPS)
x |
an polynomial matrix |
eps |
zero threshold |
Right now only matrices with numerical determinant is supported
Check if object is polyMatrix
is.polyMatrix(x)
is.polyMatrix(x)
x |
an R object |
TRUE if object is a polonial matrix
is.polyMatrix(c(1, 2, 3)) is.polyMatrix(polyMatrix(0, 2, 2))
is.polyMatrix(c(1, 2, 3)) is.polyMatrix(polyMatrix(0, 2, 2))
Tests the proper property of polynomial matrix. A polynomial matrix is proper if the associeted matrix has a full rank.
is.proper(pm) is.column.proper(pm) is.row.proper(pm)
is.proper(pm) is.column.proper(pm) is.row.proper(pm)
pm |
a polyMatrix objects |
Polynomial matrix is column (row, full) proper (or reduced) if associated matrix has same rank as the number of column (row)
True if object pm
is a (row-/column-) proper matrix
is.column.proper
: tests if its argument is a column-proper matrix
is.row.proper
: tests if its argument is a row-proper matrix
pm <- parse.polyMatrix( "-1 + 7x , x", " 3 - x + x^2, -1 + x^2 - 3 x^3" ) is.column.proper(pm) is.row.proper(pm) is.proper(pm)
pm <- parse.polyMatrix( "-1 + 7x , x", " 3 - x + x^2, -1 + x^2 - 3 x^3" ) is.column.proper(pm) is.row.proper(pm) is.proper(pm)
Generic function to check if we can treat on object as being zero. For matrices the result is a matrix of the same size.
is.zero(x, eps = ZERO_EPS) ## S4 method for signature 'polynomial' is.zero(x, eps = ZERO_EPS) ## S4 method for signature 'polyMatrix' is.zero(x, eps = ZERO_EPS)
is.zero(x, eps = ZERO_EPS) ## S4 method for signature 'polynomial' is.zero(x, eps = ZERO_EPS) ## S4 method for signature 'polyMatrix' is.zero(x, eps = ZERO_EPS)
x |
The checked object |
eps |
Minimal numerical value which will not treat as zero |
Different type of objects can be treated as a zero in different ways:
Numerical types can be compare by absolute value with eps
.
Customer types should define an an customer method.
By befault eps:
ZERO_EPS
## [1] 1e-05
TRUE if the object can be treat as zero
polynomial
: a polynomail can be treated as zero
if all its coefficients can be treated as zero
polyMatrix
: for a polunomial matrix every item is checked as polynomial
# numericals and matrices is.zero(0) ## TRUE is.zero(0.0001, eps=0.01) ## TRUE is.zero(c(0, 1, 0)) ## TRUE, FALSE, TRUE is.zero(matrix(c(1, 9, 0, 0), 2, 2)) # FALSE TRUE # FALSE TRUE # polynomials is.zero(parse.polynomial("0.1 - 0.5 x")) ## FALSE is.zero(parse.polynomial("0.0001 - 0.0005 x + 0.00002 x^2"), eps=0.01) ## TRUE
# numericals and matrices is.zero(0) ## TRUE is.zero(0.0001, eps=0.01) ## TRUE is.zero(c(0, 1, 0)) ## TRUE, FALSE, TRUE is.zero(matrix(c(1, 9, 0, 0), 2, 2)) # FALSE TRUE # FALSE TRUE # polynomials is.zero(parse.polynomial("0.1 - 0.5 x")) ## FALSE is.zero(parse.polynomial("0.0001 - 0.0005 x + 0.00002 x^2"), eps=0.01) ## TRUE
The least common multiple of polynomials or polynomial matrices.
LCM(...) ## S4 method for signature 'polyMatrix' LCM(...)
LCM(...) ## S4 method for signature 'polyMatrix' LCM(...)
... |
an list of polynomial objects |
polyMatrix
: the least common multiple of polynomial matrices
polynomial implementation polynom::GCD()
and GCD()
# LCM of polynomial matrix LCM(parse.polyMatrix( " 1 - x, 1 - x^2, 1 + 2*x + x^2", "x - x^2, 1 + x, 1 - 2*x + x^2" )) ## 0.25*x - 0.5*x^3 + 0.25*x^5
# LCM of polynomial matrix LCM(parse.polyMatrix( " 1 - x, 1 - x^2, 1 + 2*x + x^2", "x - x^2, 1 + x, 1 - 2*x + x^2" )) ## 0.25*x - 0.5*x^3 + 0.25*x^5
Returns a matrix obtained by applying a function degree()
for each element of the matrix.
matrix.degree(x) ## S4 method for signature 'matrix' matrix.degree(x) ## S4 method for signature 'polynomial' matrix.degree(x) ## S4 method for signature 'polyMatrix' matrix.degree(x)
matrix.degree(x) ## S4 method for signature 'matrix' matrix.degree(x) ## S4 method for signature 'polynomial' matrix.degree(x) ## S4 method for signature 'polyMatrix' matrix.degree(x)
x |
an R object |
Degree of each item is calculated using degree()
which is defined for polynomials
as the highest degree of the terms with non-zero coefficient.
For convenience this function is defined for any object, but returns zero for non polynomial objects.
If the argument is a matrix, the result is a matrix of the same size containing the degrees of the matrix items.
For a numerical matrix the value is always a zero matrix of the same size
For a polynomial the value is the degree of the polynomial
matrix
: the degree of a numerical matrix is a zero matrix for compatibility
polynomial
: the degree of a polynomial
polyMatrix
: a matrix of degrees for each polynomial item of the source matrix
# numerical matrices matrix.degree(matrix(1:6, 2, 3)) ## [,1] [,2] [,3] ## [1,] 0 0 0 ## [2,] 0 0 0 # polynomials matrix.degree(parse.polynomial("x + 1")) ## 1 matrix.degree(parse.polynomial("x^3 + 1")) ## 3 matrix.degree(parse.polynomial("1")) ## 0 # polynomial matrices matrix.degree(parse.polyMatrix( "x; x^2 + 1", "0; 2x")) ## [,1] [,2] ## [1,] 1 2 ## [2,] 0 1
# numerical matrices matrix.degree(matrix(1:6, 2, 3)) ## [,1] [,2] [,3] ## [1,] 0 0 0 ## [2,] 0 0 0 # polynomials matrix.degree(parse.polynomial("x + 1")) ## 1 matrix.degree(parse.polynomial("x^3 + 1")) ## 3 matrix.degree(parse.polynomial("1")) ## 0 # polynomial matrices matrix.degree(parse.polyMatrix( "x; x^2 + 1", "0; 2x")) ## [,1] [,2] ## [1,] 1 2 ## [2,] 0 1
A minor of a matrix A is the determinant of some smaller square matrix, cut down from A by removing one or more of its rows and columns. Minors obtained by removing just one row and one column from square matrices (first minors).
minor(x, r, c)
minor(x, r, c)
x |
a matrix |
r , c
|
row and column |
Build matrix of polynimal decomposition using Newton interpolation in Newton bais: (x-x_0), (x - x_0) * (x x_1)
newton(C, points)
newton(C, points)
C |
Matrix of values of polinomials in columns |
points |
point in which the values of polynomials were got |
Matrix of coefficients in columns (from higher degree to lower)
This is a convenient way to input a polynomial matrix.
parse.polyMatrix(..., var = "x")
parse.polyMatrix(..., var = "x")
... |
string or strings to parse |
var |
variable character. Only lower latin characters are allowed except 'e' which is reseved for numbers |
Space and tabulation characters are ignored.
Row should be divided by new line "\n
" or backslash "\
" (TeX style).
Elements in each row can be divided by ",
", ";
" or "&
" (TeX style)
For convenience, this function can accept multiple string. In this case each string will be treated as a new row.
This function accepts TeX matrix format.
new polynomial matrix of polyMatrix class
parse.polyMatrix(" 1, 2 + x", "2 + 2x^2, x^3") # The function can suggest mistake position in case of invalid format ## Not run: parse.polyMatrix( "1 + y & 2\\ -2 & x^2" ) ## Fail to parse polyMatrix: invalid term at position 2 in item [1, 1] ## End(Not run)
parse.polyMatrix(" 1, 2 + x", "2 + 2x^2, x^3") # The function can suggest mistake position in case of invalid format ## Not run: parse.polyMatrix( "1 + y & 2\\ -2 & x^2" ) ## Fail to parse polyMatrix: invalid term at position 2 in item [1, 1] ## End(Not run)
Parse string representation of polynomial into a polynomial object.
parse.polynomial(s, var = "x")
parse.polynomial(s, var = "x")
s |
an string for parsing |
var |
an variable name |
new polynomial as polynom::polynomial
object
This function will create polynomial object fromm coefficient matrix or signle value
polyMatrix(data, nrow, ncol, degree)
polyMatrix(data, nrow, ncol, degree)
data |
an matrix in case of creation from coefficient matrices or an numer/polynomial |
nrow |
A numer of rows of matrix. If data is a matrix, default value is the number of rows of data matrix. In other case, it's a required parameter |
ncol |
Must be positibe. If data is a matrix, default value is the number of columns of data matrix. In other ccase, it's a required parameter. |
degree |
Degree of polynomials in coefficient matrix. Can't be negative. If data is polynomail, degree can be evaluated automatcal. In other case, default value is 0. |
A coefficient matrix is a matrix which contains matrices of coefficients from lower degree to higher side-by-side
new polynomial matrix of polyMatrix class
A class to represent matrix of polinomials
## S4 method for signature 'polyMatrix,numeric' x[[i]] ## S4 method for signature 'polyMatrix' det(x) ## S4 method for signature 'polyMatrix' nrow(x) ## S4 method for signature 'polynomial' nrow(x) ## S4 method for signature 'polyMatrix' ncol(x) ## S4 method for signature 'polynomial' ncol(x) ## S4 method for signature 'polyMatrix' dim(x) ## S4 method for signature 'polyMatrix' predict(object, newdata) ## S4 method for signature 'polyMatrix' round(x, digits = 0) ## S4 method for signature 'polyMatrix' show(object) ## S4 method for signature 'polyMatrix,missing,missing,missing' x[i, j, ..., drop = TRUE] ## S4 method for signature 'polyMatrix,missing,ANY,missing' x[i, j] ## S4 method for signature 'polyMatrix,ANY,missing,missing' x[i, j] ## S4 method for signature 'polyMatrix,logical,logical,missing' x[i, j] ## S4 method for signature 'polyMatrix,logical,numeric,missing' x[i, j] ## S4 method for signature 'polyMatrix,numeric,logical,missing' x[i, j] ## S4 method for signature 'polyMatrix,numeric,numeric,missing' x[i, j] ## S4 replacement method for signature 'polyMatrix,missing,missing,ANY' x[i, j] <- value ## S4 replacement method for signature 'polyMatrix,missing,ANY,ANY' x[i, j] <- value ## S4 replacement method for signature 'polyMatrix,ANY,missing,ANY' x[i, j] <- value ## S4 replacement method for signature 'polyMatrix,numeric,numeric,numeric' x[i, j] <- value ## S4 replacement method for signature 'polyMatrix,numeric,numeric,matrix' x[i, j] <- value ## S4 replacement method for signature 'polyMatrix,numeric,numeric,polynomial' x[i, j] <- value ## S4 replacement method for signature 'polyMatrix,numeric,numeric,polyMatrix' x[i, j] <- value ## S4 method for signature 'polyMatrix,missing' e1 + e2 ## S4 method for signature 'polyMatrix,polyMatrix' e1 + e2 ## S4 method for signature 'polyMatrix,polynomial' e1 + e2 ## S4 method for signature 'polyMatrix,numeric' e1 + e2 ## S4 method for signature 'polyMatrix,matrix' e1 + e2 ## S4 method for signature 'ANY,polyMatrix' e1 + e2 ## S4 method for signature 'polyMatrix,polyMatrix' e1 == e2 ## S4 method for signature 'polyMatrix,polynomial' e1 == e2 ## S4 method for signature 'polyMatrix,matrix' e1 == e2 ## S4 method for signature 'polyMatrix,numeric' e1 == e2 ## S4 method for signature 'ANY,polyMatrix' e1 == e2 ## S4 method for signature 'polyMatrix,ANY' e1 != e2 ## S4 method for signature 'ANY,polyMatrix' e1 != e2 ## S4 method for signature 'polyMatrix,polyMatrix' x %*% y ## S4 method for signature 'polyMatrix,matrix' x %*% y ## S4 method for signature 'matrix,polyMatrix' x %*% y ## S4 method for signature 'polyMatrix,numeric' e1 * e2 ## S4 method for signature 'polyMatrix,polynomial' e1 * e2 ## S4 method for signature 'polyMatrix,polyMatrix' e1 * e2 ## S4 method for signature 'ANY,polyMatrix' e1 * e2 ## S4 method for signature 'polyMatrix,polyMatrix' e1 - e2 ## S4 method for signature 'polyMatrix,ANY' e1 - e2 ## S4 method for signature 'ANY,polyMatrix' e1 - e2
## S4 method for signature 'polyMatrix,numeric' x[[i]] ## S4 method for signature 'polyMatrix' det(x) ## S4 method for signature 'polyMatrix' nrow(x) ## S4 method for signature 'polynomial' nrow(x) ## S4 method for signature 'polyMatrix' ncol(x) ## S4 method for signature 'polynomial' ncol(x) ## S4 method for signature 'polyMatrix' dim(x) ## S4 method for signature 'polyMatrix' predict(object, newdata) ## S4 method for signature 'polyMatrix' round(x, digits = 0) ## S4 method for signature 'polyMatrix' show(object) ## S4 method for signature 'polyMatrix,missing,missing,missing' x[i, j, ..., drop = TRUE] ## S4 method for signature 'polyMatrix,missing,ANY,missing' x[i, j] ## S4 method for signature 'polyMatrix,ANY,missing,missing' x[i, j] ## S4 method for signature 'polyMatrix,logical,logical,missing' x[i, j] ## S4 method for signature 'polyMatrix,logical,numeric,missing' x[i, j] ## S4 method for signature 'polyMatrix,numeric,logical,missing' x[i, j] ## S4 method for signature 'polyMatrix,numeric,numeric,missing' x[i, j] ## S4 replacement method for signature 'polyMatrix,missing,missing,ANY' x[i, j] <- value ## S4 replacement method for signature 'polyMatrix,missing,ANY,ANY' x[i, j] <- value ## S4 replacement method for signature 'polyMatrix,ANY,missing,ANY' x[i, j] <- value ## S4 replacement method for signature 'polyMatrix,numeric,numeric,numeric' x[i, j] <- value ## S4 replacement method for signature 'polyMatrix,numeric,numeric,matrix' x[i, j] <- value ## S4 replacement method for signature 'polyMatrix,numeric,numeric,polynomial' x[i, j] <- value ## S4 replacement method for signature 'polyMatrix,numeric,numeric,polyMatrix' x[i, j] <- value ## S4 method for signature 'polyMatrix,missing' e1 + e2 ## S4 method for signature 'polyMatrix,polyMatrix' e1 + e2 ## S4 method for signature 'polyMatrix,polynomial' e1 + e2 ## S4 method for signature 'polyMatrix,numeric' e1 + e2 ## S4 method for signature 'polyMatrix,matrix' e1 + e2 ## S4 method for signature 'ANY,polyMatrix' e1 + e2 ## S4 method for signature 'polyMatrix,polyMatrix' e1 == e2 ## S4 method for signature 'polyMatrix,polynomial' e1 == e2 ## S4 method for signature 'polyMatrix,matrix' e1 == e2 ## S4 method for signature 'polyMatrix,numeric' e1 == e2 ## S4 method for signature 'ANY,polyMatrix' e1 == e2 ## S4 method for signature 'polyMatrix,ANY' e1 != e2 ## S4 method for signature 'ANY,polyMatrix' e1 != e2 ## S4 method for signature 'polyMatrix,polyMatrix' x %*% y ## S4 method for signature 'polyMatrix,matrix' x %*% y ## S4 method for signature 'matrix,polyMatrix' x %*% y ## S4 method for signature 'polyMatrix,numeric' e1 * e2 ## S4 method for signature 'polyMatrix,polynomial' e1 * e2 ## S4 method for signature 'polyMatrix,polyMatrix' e1 * e2 ## S4 method for signature 'ANY,polyMatrix' e1 * e2 ## S4 method for signature 'polyMatrix,polyMatrix' e1 - e2 ## S4 method for signature 'polyMatrix,ANY' e1 - e2 ## S4 method for signature 'ANY,polyMatrix' e1 - e2
x |
an matrix object |
i |
the degree to extract matrix of coefficient |
object |
an R object |
newdata |
the value to evaluate |
digits |
integer indicating the number of decimal places (round) or significant digits (signif) to be used |
j |
column indeces |
... |
unused |
drop |
unused |
value |
new value |
e1 |
an left operand |
e2 |
an right operand |
y |
second argument |
[[
: get coefficient matrix by degree
det
: determinant of a polynomial matrix
nrow
: number of rows of a polynomial matrix
nrow
: an polynomial has only one row
ncol
: number of column of a polynomial matrix
ncol
: an polynomial has only one column
dim
: dimension of a polynomial matrix
predict
: value of polynomial matrix in point
round
: round of polynomial matrix is rounding of polynomial coefficients
show
: prints out a text representation of a polynomial matrix
[
: get matrix content
[
: get columns
[
: get rows
[
: get by logical index
[
: get by logical index and numerical indeces
[
: get by logical index and numerical indeces
[
: get by row and column indeces
[<-
: replace matrix content
[<-
: assign rows
[<-
: assign columns
[<-
: assign part of matrix with number
[<-
: assign part of matrix with another matrix
[<-
: assign part of matrix with polynomial
[<-
: assign part of matrix with another polynomial matrix
+
: summation with polynomial matrix
+
: summation of polynomial matrices
+
: summation of polynomial matrix and scalar polynomial
+
: summation of polynomial matrix and scalar nummber
+
: summation of polynomial matrix and numerical matrix
+
: summation of 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
%*%
: matrix multiplicatoin of polynomial matrices
%*%
: matrix multiplicatoin of polynomial and numerical matrices
%*%
: matrix multiplicatoin of numerical and polynomial matrices
*
: scalar multiplication with number
*
: scalar multiplication with polynomial
*
: scalar multiplication of polynomial mattrices elementwise
*
: scalar multiplication
-
: substractioin
-
: substractioin
-
: substractioin
coef
A matrix of coefficients which are joined into one matrix from lower degree to higher
ncol
Actual number of columns in the polynomial matrix
# 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
# 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
Apply function to each element of matrix
polyMatrix.apply(x, f)
polyMatrix.apply(x, f)
x |
an polynomial matrix |
f |
an function with only one argument |
Given a polyMatrix, t
returns the transpose of x
## S4 method for signature 'polyMatrix' t(x)
## S4 method for signature 'polyMatrix' t(x)
x |
a polyMatrix |
base::t()
for numerical matrix tranpose
pm <- parse.polyMatrix("1, x, x^2", "x, 1, x^3") t(pm) ## [,1] [,2] ## [1,] 1 x ## [2,] x 1 ## [3,] x^2 x^3
pm <- parse.polyMatrix("1, x, x^2", "x, 1, x^3") t(pm) ## [,1] [,2] ## [1,] 1 x ## [2,] x 1 ## [3,] x^2 x^3
Trace of a matrix is the sum of the diagonal elements of the given matrix.
tr(x)
tr(x)
x |
an matrix or a polynomial matrix |
If the given matrix is a polynomial matrix, the result will be a polynomial.
Returns the trace of the given matrix as a number or a polynomial.
# numerical matrices m <- matrix(1:12, 3, 4) ## [,1] [,2] [,3] [,4] ## [1,] 1 4 7 10 ## [2,] 2 5 8 11 ## [3,] 3 6 9 12 tr(m) ## 15 # polynomial matrix pm <- parse.polyMatrix( "-3 + x^2, 2 + 4 x, -x^2", " 1, 2, 3 + x", " 2*x, 0, 2 - 3 x" ) tr(pm) ## 1 - 3*x + x^2
# numerical matrices m <- matrix(1:12, 3, 4) ## [,1] [,2] [,3] [,4] ## [1,] 1 4 7 10 ## [2,] 2 5 8 11 ## [3,] 3 6 9 12 tr(m) ## 15 # polynomial matrix pm <- parse.polyMatrix( "-3 + x^2, 2 + 4 x, -x^2", " 1, 2, 3 + x", " 2*x, 0, 2 - 3 x" ) tr(pm) ## 1 - 3*x + x^2
The parameters point_vector
, round_digits
can significantly affect the result.
triang_Interpolation( pm, point_vector, round_digits = 5, eps = .Machine$double.eps^0.5 )
triang_Interpolation( pm, point_vector, round_digits = 5, eps = .Machine$double.eps^0.5 )
pm |
source polynimial matrix |
point_vector |
vector of interpolation points |
round_digits |
we will try to round result on each step |
eps |
calculation zero errors |
Default value of 'eps“ usually is enought to determintate real zeros.
In a polynomial matrix the head elements are the first non-zero polynomials of columns. The sequence of row indices of this head elements form the shape of the polynomial matrix. A polynomial matrix is in left-lower triangular form, if this sequence is monoton increasing.
This method offers a solution of the triangulrization by the Interpolation method, described in the article of Labhalla-Lombardi-Marlin (1996).
Tranfortmaiton matrix
The function triang_Sylvester
triangularize the given polynomial matrix.
triang_Sylvester(pm, u, eps = ZERO_EPS)
triang_Sylvester(pm, u, eps = ZERO_EPS)
pm |
an polynomial matrix to triangularize |
u |
the minimal degree of the triangularizator multiplicator |
eps |
threshold of non zero coefficients |
The u
parameter is a necessary supplementary input without default value.
This parameter give the minimal degree of the searched triangulizator to solve the problem.
In a polynomial matrix the head elements are the first non-zero polynomials of columns. The sequence of row indices of this head elements form the shape of the polynomial matrix. A polynomial matrix is in left-lower triangular form, if this sequence is monoton increasing.
This method search a solution of the triangulrization by the method of Sylvester matrix, descripted in the article Labhalla-Lombardi-Marlin (1996).
T - the left-lower triangularized version of the given polynomial matrix U - the right multiplicator to triangularize the given polynomial matrix
Salah Labhalla, Henri Lombardi, Roger Marlin: Algorithm de calcule de la reduction de Hermite d'une matrice a coefficients polynomiaux, Theoretical Computer Science 161 (1996) pp 69-92
Get zero lead hyper rows of size sub_nrow of matrix M
zero_lead_hyp_rows(M, sub_nrow, esp = ZERO_EPS)
zero_lead_hyp_rows(M, sub_nrow, esp = ZERO_EPS)
M |
Numerical matrix |
sub_nrow |
Size of hyper row |
esp |
Machine epsilon to determinate zeros |
vector of idx of hyperrows, NaN for columns without zeros
Get zero lead rows of matrix M
zero_lead_rows(M, eps = ZERO_EPS)
zero_lead_rows(M, eps = ZERO_EPS)
M |
Numerical matrix |
eps |
Machine epsilon to determinate zeros |
vector of idx (length is equal to columm number), NULL in case of error
Rounds object to zero if it's too small
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)
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)
x |
an R object |
eps |
Minimal numerical value which will not treat as zero |
By befault eps:
ZERO_EPS
## [1] 1e-05
polynomial
: rounding of a polynomial means rounding of each coefficient
polyMatrix
: rounding of a polynomial matrix
# 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
# 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