search for: sum

Displaying 20 results from an estimated 11007 matches for "sum".

Did you mean: num
2009 Oct 26
1
[PATCH] Fix miscompile of SSE resampler
...- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/libspeex/resample.c b/libspeex/resample.c index 7b5a308..8131380 100644 --- a/libspeex/resample.c +++ b/libspeex/resample.c @@ -361,7 +361,7 @@ static int resampler_basic_direct_single(SpeexResamplerState *st, spx_uint32_t c sum = accum[0] + accum[1] + accum[2] + accum[3]; */ #else - sum = inner_product_single(sinc, iptr, N); + inner_product_single(&sum, sinc, iptr, N); #endif out[out_stride * out_sample++] = SATURATE32(PSHR32(sum, 15), 32767); @@ -412,7 +412,7 @@ static int resampler_basic_direct...
2005 Jun 24
1
r programming help II
...console, > k<-0;j<-0;i<-(1:7)+30*j+7*k;K.JUN[i];rle(K.JUN[i]) [1] 1 0 1 1 1 1 1 Run Length Encoding lengths: int [1:3] 1 1 5 values : num [1:3] 1 0 1 where k=0,1,2,3 for each j=0 to 18 (k indicating weeks of any June, and j indicates years 1984-2002 respectively). Now we need to sum the run 'lengths' corresponding to each 'values' "1" (that is 'lengths' of each "0" 'values' need to be excluded) for all k=0,1,2,3 for each j=0 to 18 (for example, for k<-0;j<-0 we find 'lengths' 1 and 5 for 'values' "1...
2007 Aug 24
1
Speex on ARM7
...;m using FIXED_POINT. Unfortunately the encoding speed is about 5 times slower then necessary for real time. ARM7 is slow for 16/8 bits operations. The sequence: static inline spx_word32_t compute_pitch_error(spx_word16_t *C, spx_word16_t *g, spx_word16_t pitch_control) { spx_word32_t sum = 0; sum = ADD32(sum,MULT16_16(MULT16_16_16(g[0],pitch_control),C[0])); sum = ADD32(sum,MULT16_16(MULT16_16_16(g[1],pitch_control),C[1])); sum = ADD32(sum,MULT16_16(MULT16_16_16(g[2],pitch_control),C[2])); sum = SUB32(sum,MULT16_16(MULT16_16_16(g[0],g[1]),C[3])); sum = SUB32(sum...
2003 Mar 30
1
[RFC][patch] dynamic rolling block and sum sizes II
Mark II of the patch set. The first patch (dynsumlen2.patch) increments the protocol version to support per-file dynamic block checksum sizes. It is a prerequisite for varsumlen2.patch. varsumlen2.patch implements per-file dynamic block and checksum sizes. The current block size calculation only applies to files between 7MB and 160MB setting th...
2011 Aug 14
3
Not sure how to use aggregate, colSums, by
I have a data frame called test shown below that i would like to summarize in a particular way : I want to show the column sums (columns y ,f) grouped by country (column e1). However, I'm looking for the data to be split according to column e2. In other words, two tables of sum by country. One table for "con" and one table for "std" shown in...
2008 Nov 26
1
SSE2 code won't compile in VC
...nd vice versa. While there are intrinsics to do the casts, I thought it would be simpler to just use an intrinsic that accomplishes the same thing without all the casting. Thanks, --John @@ -91,7 +91,7 @@ static inline double inner_product_double(const float *a, const float *b, unsign sum = _mm_add_pd(sum, _mm_cvtps_pd(t)); sum = _mm_add_pd(sum, _mm_cvtps_pd(_mm_movehl_ps(t, t))); } - sum = _mm_add_sd(sum, (__m128d) _mm_movehl_ps((__m128) sum, (__m128) sum)); + sum = _mm_add_sd(sum, _mm_unpackhi_pd(sum, sum)); _mm_store_sd(&ret, sum); return ret; } @@ -1...
2003 Dec 30
1
Accuracy: Correct sums in rowSums(), colSums() (PR#6196)
Full_Name: Nick Efthymiou Version: R1.5.0 and above OS: Red Hat Linux Submission from: (NULL) (162.93.14.73) With the introduction of the functions rowSums(), colSums(), rowMeans() and colMeans() in R1.5.0, function "SEXP do_colsum(SEXP call, SEXP op, SEXP args, SEXP rho)" was added to perform the fast summations. We have an excellent opportunity to improve the accuracy by implementing Kahan summation here. Kahan summation is described in...
2001 Aug 21
4
looking for a smarter way
...me in each cluster. The code does what I want, but I have other examples where I have hundreds of clusters and I would prefer not to have to type in a line for each cluster. Again, there must be a way and I would appreciate any suggestions: xtab<-table(x$LOCAL.NAME,xclu$clustering) xshw1<--sum((xtab[,1]+0.000001)/sum(xtab[,1])*(log((xtab[,1]+0.000001)/sum(x tab[,1])))) xshw2<--sum((xtab[,2]+0.000001)/sum(xtab[,2])*(log((xtab[,2]+0.000001)/sum(x tab[,2])))) xshw3<--sum((xtab[,3]+0.000001)/sum(xtab[,3])*(log((xtab[,3]+0.000001)/sum(x tab[,3])))) xshw4<--sum((xtab[,4]+0.000001)/sum...
2011 Feb 04
4
aggregate function - na.action
...e( x1=sample(c(NA,'m','f'), 100, replace=TRUE), x2=sample(c(NA, 1:10), 100, replace=TRUE), x3=sample(c(NA,letters[1:5]), 100, replace=TRUE), x4=sample(c(NA,T,F), 100, replace=TRUE), y=sample(c(rep(NA,5), rnorm(95)))) dat ## The total from dat: sum(dat$y, na.rm=T) ## The total from aggregate: sum(aggregate(dat$y, dat[,1:4], sum, na.rm=T)$x) sum(aggregate(y~x1+x2+x3+x4, data=dat, sum, na.rm=T)$y) ## <--- This line gave an error in a separate R instance ## The aggregate formula is excluding NA ## So, let's try to include NAs sum(aggreg...
2007 Oct 18
12
first cut at blockless given/when/then
Hi all, I committed a first cut at blockless Givens/Whens/Thens to RSpec''s trunk: cd /path/to/rspec/project svn up cd rspec bin/spec examples/story/calculator.rb Take a look at examples/story/calculator.rb to see what''s going on. Needs docs!!!! Thoughts welcome. I''ve also got a cut at the plain text parser checked in, but it''s not hooked up to anything
2018 Mar 16
1
Discrepancy: R sum() VS C or Fortran sum
My simple functions were to compare the result with the gfortran compiler sum() function. I thought that the Fortran sum could not be less precise than R. I was wrong. I am impressed. The R sum does in fact match the result if we use the Kahan algorithm. P. I am glad to see that R sum() is more accurate than the gfortran compiler sum. On 16/03/18 11:37 AM, luke-tierne...
2018 Mar 16
3
Discrepancy: R sum() VS C or Fortran sum
Hi all, I found a discrepancy between the sum() in R and either a sum done in C or Fortran for vector of just 5 elements. The difference is very small, but this is a very small part of a much larger numerical problem in which first and second derivatives are computed numerically. This is part of a numerical method course I am teaching in w...
2014 Feb 08
3
[PATCH 1/2] arm: Use the UAL syntax for ldr<cc>h instructions
On Fri, 7 Feb 2014, Timothy B. Terriberry wrote: > Martin Storsjo wrote: >> This is required in order to build using the built-in assembler >> in clang. > > These patches break the gcc build (with "Error: bad instruction"). Ah, right, sorry about that. > Documentation I've seen is contradictory on which order ({cond}{size} or > {size}{cond}) is correct.
2009 Jun 02
2
reference counting bug: overwriting for loop 'seq' variable
It looks like the 'seq' variable to 'for' can be altered from within the loop, leading to incorrect answers. E.g., in the following I'd expect 'sum' to be 1+2=3, but R 2.10.0 (svn 48686) gives 44.5. > x = c(1,2); sum = 0; for (i in x) { x[i+1] = i + 42.5; sum = sum + i }; sum [1] 44.5 or, with a debugging cat()s, > x = c(1,2); sum = 0; for (i in x) { cat("before, i=", i, "\n"); x[i+1] = i + 42.5; cat(&...
2010 Jul 07
2
Sum vectors and numbers
We want to sum many vectors and numbers together as a vector if there is at least one vector in the arguments. For example, 1 + c(2,3) = c(3,4). Since we are not sure arguments to sum, we are using sum function: sum(v1,v2,...,n1,n2,..). The problem is that sum returns the sum of all the values present in its argu...
2003 Mar 23
1
[RFC] dynamic checksum size
...matically if the user didn't specify a block size. Unfortunately that isn't enough and the block size would need to grow faster than the file. Besides, overly large block sizes mean large amounts of data need to be copied even for small changes. The maths indicate that increasing the checksum length would rapidly get eliminate the problem. However, increasing the checksum length regardless of file size burns bandwidth so per-file checksum sizes were wanted. Unfortunately that required a protocol bump which was undesirable at the time. The two attached patches implement per-file dynami...
2010 Jun 24
5
Best way to compute a sum
> a <- 0 ; for(i in (1:200000000)) a <- a + 1/i > b <- 0 ; for(i in (200000000:1)) b <- b + 1/i > c <- sum(1/(1:200000000)) > d <- sum(1/(200000000:1)) > order(c(a,b,c,d)) [1] 1 2 4 3 > b<c [1] TRUE > c==d [1] FALSE I'd expected b being the largest, since we sum up the smallest numbers first. Instead, c is the largest, which is sum() applied to the vector ordered w...
2012 Feb 10
2
Discrete Event Simulation problem
...START = 0 GetDemand<-function() START + runif(1,min=0,max=2) main <- function(t.max,maxStock,minStock) { index = 0 t.current = START #### Starting Conditions t.demand = START t.supply = START inventory = 50 order_costs = 0 storage_costs = 0 sales = 0 sum = list(inventory = 50,order_costs = 0,storage_costs = 0,sales =0) while(index < LAST){ index = index + 1 t.demand = GetDemand() ### expected time to next sale t.supply = Inf ### expected time to arrival of order, Infinity as order has not been placed t.next =min(t.demand,t.supply) ###...
2012 Sep 20
3
Problem with Newton_Raphson
...r=5000 U<-runif(n,0,1) for (i in 1:rr){ x<-(-log(1-U^(1/p1))/b) ?meantrue<-gamma(1+(1/p1))*b ? meantrue ? d<-meantrue/0.30 ? cen<- runif(n,min=0,max=d) ? s<-ifelse(x<=cen,1,0) ? q<-c(x,cen) ? ? z<-function(data, p){? ? ? shape<-p[1] ? ? scale<-p[2] ? ? log1<-n*sum(s)*log(p[1])+ n*sum(s)*log(p[2])+(p[1]-1)*sum(s)*log(1-((exp(-(p[2])*sum(x))))) -(p[2])*sum(t) + (p[1])*log((exp(-(p[2])*sum(x))))- (p[1])*sum(s)*log((exp(-(p[2])*sum(x)))) ? return(-log1) ? } } ? start <- c(1,1) ? zz<-optim(start,fn=z,data=q,hessian=T) ? zz ? m1<-zz$par[2] ? p<-zz$par[...
2014 Jul 03
5
[LLVMdev] Global constructors "get lost" when transforming bitcode files
...A strange problem appears when upgrading from release_34 to testing. Some transformations to bitcode files cause registered global_ctors to not be called. Here's an example (I've also attached the complete example and pasted it below): This works: clang -fsanitize=address -flto -c -o sum.o sum.c clang -fsanitize=address -o sum sum.o This doesn't work: clang -fsanitize=address -flto -c -o sum.o sum.c llvm-dis sum.o llvm-as sum.o.ll -o sum.o clang -fsanitize=address -o sum sum.o The second version segfaults when accessing shadow memory, because the memory...