The ‘polynom::predict.polynomial()
’ method works by real coefficients
only but it works for real or complex and matrix argument also.
But in the case of matrix argument uses the elementwise product.
The ‘polyMatrix::predict
’ method evaluate the polynom by
the usual matrix product definition.
# S3 method for charpn
predict(object,pM,...)
a ‘charpn’ class object
a ‘polyMatrix’ class object
additional arguments
A ‘polynomial’ class object
# NOT RUN {
pm <- polyMgen.d(2,2,rawData=ch2pn(c("1","x^2","x","0")))
pm # 1, z^2\\ z, 0
predict(pm,2) # matrix(c(1,4,2,0),2)
# predict the result of a linear model
x <- 1:5;y <- rnorm(5);predict(lm(y~x)) # the used method: predict.lm()
# clean up
# rm(pm, x, y)
# }
Run the code above in your browser using DataLab