Displaying 1 result from an estimated 1 matches for "prodsub".
Did you mean:
prodsum
2009 Jul 21
1
Elementary Symmetric Polynomials
...ed values of the elementary symmetric polynomials in t
variables. Below is what we have at the moment, but it is a little slow
for our needs. Any suggestions?
Thanks ahead of time for any help you can offer,
Austin H. Jones
Department of Mathematics
Wake Forest University
f<-function(v)
{
prodsub<-function(v,q){prod(v[q])}
t<-length(v)
C<-vector("list",t)
for (i in 1:t)
{C[[i]]<-combn(1:t,i)}
e<-rep(0,t)
for (i in 1:(t))
{
e[i]<-sum(apply(C[[i]],2,prodsub,v=v))
}
e<-c(1,e)
e
}
Examples:
> f(c(1,2,3))
[1] 1 6 11 6
> f(c(4,6,3,1,9))
[1] 1 23...