Displaying 3 results from an estimated 3 matches for "totalsum".
2006 Jan 30
4
Loops that last for ever...
...ions for each of the [[i]] ? Using
probably apply? or constructing a specific function? or using the
so-called "vectorising" tricks?
One example could be the following, that calculates the sums 1:5,
2:6, 3:7,..., for each of xs[[i]] :
xs <- lapply(1:500, function(x) rnorm(1000))
totalsum <- list()
sums <- list()
first <- list()
for(i in 1:length(xs)) {
totalsum[i] <- sum(xs[[i]])
for(j in 1:length(xs[[i]])) {
if(j == 1) {
sums[[i]] <- list()
}
if(j >= 5) {
sums[[i]][j] <- sum(xs[[i]][(j-4):j])
}
}
}
Of course the functions I actually call a...
2011 Dec 16
0
crash in using Rcpp and inline packages.
...des in mkc.cpp file are:
NumericVector fx(fx0);
NumericVector fy(fy0);
NumericVector fsp(fsp0);
NumericVector x(x0);
NumericVector y(y0);
NumericVector sp(sp0);
NumericMatrix phyd(phyd0);
double rmax = as<double>(rmax0);
double step = as<double>(step0);
double totalcout = 0.0;
double totalsum = 0.0;
int binlength = as<int> (binlength0);
NumericVector bincout(binlength);
NumericVector binsum(binlength);
int nfocal=fx.size();
int ntotal=x.size();
double dist =0.0;
double ibin = 0.0;
double lpd = 0.0;
typedef NumericVector::iterator vec_iterator;
vec_iterator ifx = fx.begin(), if...
2011 Dec 16
0
Fw: crash in using Rcpp and inline packages.
...des in mkc.cpp file are:
NumericVector fx(fx0);
NumericVector fy(fy0);
NumericVector fsp(fsp0);
NumericVector x(x0);
NumericVector y(y0);
NumericVector sp(sp0);
NumericMatrix phyd(phyd0);
double rmax = as<double>(rmax0);
double step = as<double>(step0);
double totalcout = 0.0;
double totalsum = 0.0;
int binlength = as<int> (binlength0);
NumericVector bincout(binlength);
NumericVector binsum(binlength);
int nfocal=fx.size();
int ntotal=x.size();
double dist =0.0;
double ibin = 0.0;
double lpd = 0.0;
typedef NumericVector::iterator vec_iterator;
vec_iterator ifx = fx.begin(), if...