Skip to content

Instantly share code, notes, and snippets.

@carlganz
Created January 13, 2017 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlganz/c6157ee8fed1b2bd39c25e0f8e517465 to your computer and use it in GitHub Desktop.
Save carlganz/c6157ee8fed1b2bd39c25e0f8e517465 to your computer and use it in GitHub Desktop.
Lumley Blog Post
setMethod("%*%", c("gammaconv","gammaconv"), function(x,y) {
# maxterms<-sum(outer(x@power,y@power,function(n1,n2) 2*pmax(n1+1,n2+1)))
allcoef<- list() #numeric(maxterms)
allpower<- list() #integer(maxterms)
allexp<- list() #numeric(maxterms)
# here<-0
iterator <- 1
for(i in 1:length(x@power)){
for(j in 1:length(y@power)){
if (x@exp[i]==y@exp[j]) {cat("#");next}
term<-convone(x@exp[i],x@power[i],y@exp[j],y@power[j])
# size<-nrow(term)
# if(here+size>maxterms) stop("thomas can't count")
# allcoef[here+(1:size)]<-term@coef*x@coef[i]*y@coef[j]
# allpower[here+(1:size)]<-term@power
# allexp[here+(1:size)]<-term@exp
# here<-here+size
allcoef[[iterator]] <- term@coef*x@coef[i]*y@coef[j]
allpower[[iterator]] <- term@power
allexp[[iterator]] <- term@exp
iterator <- iterator + 1
}
}
new("gammaconv", coef=unlist(allcoef),power=unlist(allpower),exp=unlist(allexp))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment