File: convolve11_cpp.cpp

package info (click to toggle)
rcpp 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,480 kB
  • sloc: cpp: 27,436; ansic: 7,778; sh: 53; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 626 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-

// This version uses nona to indicate that xb does not contain any missing
// value. This is the assumption that all other versions do.

#include <Rcpp.h>
using namespace Rcpp ;


RcppExport SEXP convolve11cpp(SEXP a, SEXP b) {
    NumericVector xa(a); int n_xa = xa.size() ;
    NumericVector xb(b); int n_xb = xb.size() ;
    NumericVector xab(n_xa + n_xb - 1,0.0);

    Range r( 0, n_xb-1 );
    for(int i=0; i<n_xa; i++, r++){
    	xab[ r ] += noNA(xa[i]) * noNA(xb) ;
    }
    return xab ;
}

#include "loopmacro.h"
LOOPMACRO_CPP(convolve11cpp)