Learn R Programming

cladoRcpp (version 0.15.1)

rcpp_convolve: Run C++ version of convolve(x,y, conj=TRUE, type="open")

Description

This function runs a C++ version of the R function convolve, specifically: convolve(x,y, conj=TRUE, type="open")

Usage

rcpp_convolve(a, b)

Arguments

a

a numeric vector

b

a numeric vector

Value

convolve_result_vector the vector which is the product of the convolution

Details

The R function convolve is an example of an R function that gets very slow when the input vectors are large. This C++ version, rcpp_convolve can be dramatically faster for large vectors.

rcpp_convolve produces the same output as: convolve(ca, cb, conj=TRUE, type="open")

Note: The C++ code is from the Rcpp examples in: Eddelbuettel & Francois (2011). Rcpp: Seamless R and C++ Integration. Journal of Statistical Software, 40(8), 1-18.

See Also

Rcpp, convolve, rcpp_mult2probvect, Rcpp_combn_zerostart #bibliography /Dropbox/_njm/__packages/cladoRcpp_setup/cladoRcpp_refs.bib @cite Eddelbuettel_Francois_2011

Examples

Run this code
# NOT RUN {
# Set up 2 vectors, then convolve them
ca = c(1,2,3,4,5)
cb = c(2,2,2,2,2)
rcpp_convolve(a=ca, b=cb)

# Same as:
convolve(ca, cb, conj=TRUE, type="open")

# }

Run the code above in your browser using DataLab