functions{
vector convolution(int N, real tStep, vector aif, vector irf){
vector<lower=0>[N] ctr;
for(i in 1:N){ ctr[i] <- 0.0; for(j in 1:i){ ctr[i] <- ctr[i] + aif[i - j + 1] * irf[j]; } } return ctr*tStep; }functions{
vector convolution(int N, real tStep, vector aif, vector irf){
vector<lower=0>[N] ctr;
vector<lower=0>[N] summand;
for(i in 1:N){
summand <- rep_vector(0, N);
for(j in 1:i){
summand[j] <- aif[i - j + 1] * irf[j];
}
ctr[i] <- sum(summand);
}
return ctr*tStep;
}Cheers
Tammo
functions{
vector convolution(int N, real tStep, vector aif, vector irf){
vector<lower=0>[N] ctr;
for(i in 1:N){
vector<lower=0>[i] summand;
for(j in 1:i){
summand[j] <- aif[i - j + 1] * irf[j];
}
ctr[i] <- sum(summand);
}
return ctr*tStep;
}
--
You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thanks! It works and it is faster than before, but it's still slower (by about 10% for the few tests I ran) than the non-vectorized Version 1.
P.S. I've tried to restrict the term "vectorized" to when
a function can take a vector for an argument as well as
a scalar, and that's not what's going on here. But it's
used all over in different ways in other packages and by
other people, so it's probably a hopeless battle to restrict
its technical meaning.