Already available in Rcpp 0.8.3, the new sugar feature was extended in 0.8.4 to cover more functions, and we have now started to adapt sugar for matrices with functions such as outer, row, diag, etc ...
Here is an example of using the sugar version of outer
NumericVector xx(x) ; NumericVector yy(y); NumericMatrix m = outer( xx, yy, std::plus<double>() ) ; return m ;
This mimics the R code
> outer( x, y, "+" )
Here is the relevant extract of the NEWS file:
0.8.4 2010-07-09 o new sugar vector functions: rep, rep_len, rep_each, rev, head, tail, diag o sugar has been extended to matrices: The Matrix class now extends the Matrix_Base template that implements CRTP. Currently sugar functions for matrices are: outer, col, row, lower_tri, upper_tri, diag o The unit tests have been reorganised into fewer files with one call each to cxxfunction() (covering multiple tests) resulting in a significant speedup o The Date class now uses the same mktime() replacement that R uses (based on original code from the timezone library by Arthur Olson) permitting wide dates ranges on all operating systems o The FastLM/example has been updated, a new benchmark based on the historical Longley data set has been added o RcppStringVector now uses std::vector<std::string> internally o setting the .Data slot of S4 objects did not work properly