powered by
Calculate sum(x^2), but faster when the number of elements exceeds 1000.
sum(x^2)
double, integer, or logical vector/matrix
A numerical scalar
# NOT RUN { x <- rnorm(10000) sumsquared(x) # Compare speed microbenchmark::microbenchmark( cpp = {sumsquared(x)}, r = {sum(x^2)} ) # }
Run the code above in your browser using DataLab