Learn R Programming

polyMatrix (version 0.2.5)

polyMgen: Generate a polyMatrix class polynomial matrix

Description

A complex tool to generate a polynomial matrix in ‘polyMatrix’ form. The ‘polyMatrix’ object contains the following three invariant elements: the $dim, $degree and $symb independently of the sub-class of the object. The $dim is the size of the matrix. The $degree is a matrix of non-negetive numbers, the degree of the polynomial elements of the polynomial matrix. The $symb the symbol to print and identify the reference to the algebraic set over which the polynom defined -- sorry, this option not fully works.

Usage

polyMgen(nrow,ncol,rawData,symb,rand,degree,byrow,sm="polyMarray",...)

Arguments

nrow

the desired number of rows

ncol

the desired number of columns

degree

the desired degrees of polynomials when it is filled randomly

rawData

the data to fill with the polynomial matrix. In case of polyMgen.a, polyMgen.b and polyMgen.c a vector of the required coefficients of the polynomials. The case of polyMgen.d is different: here the rawData is a list of polynomial class objects

symb

the desired polynom symbol

rand

the name of the random generator used to generate the coefficients of a random polynomial matrix

byrow

logical. If FALSE (the default) the matrix is filled by columns, if TRUE the matrix is filled by rows

sm

storage method: polyMarray (the default) or\ polyMbroad, polyMcells, polyMdlist

additional arguments

Value

A polyMatrix class object with a sub-class polyMarray, polyMbroad, polyMcells or polyMdlist.

Details

The four possible methods to generate the polynomial matrix from the given material rawData or (the default) or random values:

  • ‘array’, when the coefficient matrices of the polinomial matrix are stored in two independent element of the list of the polyMatrix: the constant matrix in $const, and the coefficients of the first, second... degree of the polynomial in the first, second,... element of the $array. In this case the sub-class of the generated polyMatrix object is polyMarray.

  • ‘broad-matrix’, when the coefficients are stored in one broad matrix in the $broad element of the polyMatrix object. The size of this broad matrix is: nrow x (ncol*(d+1)), when the degree of the nrow x ncol size polynomial matrix is d. In this case the sub-class of the generated polyMatrix object is polyMbroad.

  • ‘list of cells’, when the nrow x ncol size coefficient matrices are stored in d+1 element of the $cells list element of the polyMatrix object. In this case the sub-class of the generated polyMatrix object is polyMcells.

  • ‘double list’, when the elements of the polynomial matrix are stored in the form of polynomial class objects in a nrow x ncol element double list. In this case the sub-class of the generated polyMatrix object is polyMdlist.

See Also

polyMatrix-package, polyMgen.a, polyMgen.b, polyMgen.c, polyMgen.d

Examples

Run this code
# NOT RUN {
polyMgen.a() # default size & coefficients & rank

polyMgen.a(2,3,1:6) # given coefficients & default rank
polyMgen.a(2,3,1:6,degree=1) # given coefficients & rank
polyMgen.a(2,3,1:36,degree=matrix(0:5,2,3)) # given coefficients & ranks
polyMgen.a(2,3,1:12,degree=matrix(2:0,2,3)) # given coefficients & ranks

polyMgen.a(rand=TRUE) # normally distributed coefficients

polyMgen.a(rand=rexp) # exponentially distributed coefficients

pois.vg.fv <- function(x) rpois(x,1)
polyMgen.a(rand=pois.vg.fv) # Poisson(1) distributed coefficients
rm(pois.vg.fv)

polyMgen.b() # class="polyMbroad", broad matrix form
polyMgen.c() # class="polyMcells", list of coefficient matrices
polyMgen.d() # class="polyMdlist", dubble list

polyMgen.d(2,2,
  rawData=list(polynom::polynomial(1),
               polynom::polynomial(c(0,0,1)),
               polynom::polynomial(c(0,1)),
               polynom::polynomial(0)))

px <- polyMgen.d(3,3,rawData=ch2pn(
     c("-3 + z^2","2 + 4*z","-z^2",
       "1","2","3 + z",
       "2*z","0","2 - 3*z"),"z"))
class(px) # "polyMdlist" "polyMatrix"
px

px <- polyMgen.d(3,3,rawData=ch2pn(
     c("-3 + z^2","2 + 4*z","-z^2",
       "1","2","3 + z",
       "2*z","0","2 - 3*z"),"z"),byrow=TRUE)
class(px) # "polyMdlist" "polyMatrix"
px

polyMgen.d()
polyMgen.d(rand=TRUE)
polyMgen.d(rand=TRUE,degree=2)
polyMgen.d(degree=3)
polyMgen.d(degree=NULL)

# clean up
# rm(px)

# }

Run the code above in your browser using DataLab