[Rcpp-commits] r2594 - in pkg/RcppGSL/inst: doc/RcppGSL examples/RcppGSLExample/man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Nov 29 18:05:43 CET 2010


Author: edd
Date: 2010-11-29 18:05:43 +0100 (Mon, 29 Nov 2010)
New Revision: 2594

Modified:
   pkg/RcppGSL/inst/doc/RcppGSL/RcppGSL.Rnw
   pkg/RcppGSL/inst/examples/RcppGSLExample/man/colNorm.Rd
Log:
documented (and then discuss) the plain R alternative to colNorm


Modified: pkg/RcppGSL/inst/doc/RcppGSL/RcppGSL.Rnw
===================================================================
--- pkg/RcppGSL/inst/doc/RcppGSL/RcppGSL.Rnw	2010-11-29 14:48:16 UTC (rev 2593)
+++ pkg/RcppGSL/inst/doc/RcppGSL/RcppGSL.Rnw	2010-11-29 17:05:43 UTC (rev 2594)
@@ -507,11 +507,21 @@
 
 The \pkg{RcppGSL} package contains a complete example providing a single
 function \texttt{colNorm} which computes a norm for each column of a
-supplied. This example adapts a matrix example from the GSL manual as has
+supplied matrix. This example adapts a matrix example from the GSL manual that has
 been chose merely as a means to showing how to set up a package to use
-\pkg{RcppGSL}. Needless to say, we could compute such a matrix norm easily in
-\proglang{R} using existing facilities.
+\pkg{RcppGSL}.
 
+Needless to say, we could compute such a matrix norm easily in \proglang{R}
+using existing facilities. One such possibility is a simple
+\verb|apply(M, 2, function(x) sqrt(sum(x^2)))| as shown on the corresponding
+help page in the example package inside \pkg{RcppGSL}. One point in favour of
+using the \pkg{GSL} code is that it employs a BLAS function so on
+sufficiently large matrices, and with suitable BLAS libraries installed, this
+variant could be faster due to the optimised code in high-performance BLAS
+libraries and/or the inherent parallelism a multi-core BLAS variant which
+compute compute the vector norm in parallel.  On all `reasonable' matrix
+size, however, the performance difference should be neglible.
+
 \subsection{The \texttt{configure} script}
 
 Using \pkg{RcppGSL} means employing both the \pkg{GSL} and \proglang{R}. We

Modified: pkg/RcppGSL/inst/examples/RcppGSLExample/man/colNorm.Rd
===================================================================
--- pkg/RcppGSL/inst/examples/RcppGSLExample/man/colNorm.Rd	2010-11-29 14:48:16 UTC (rev 2593)
+++ pkg/RcppGSL/inst/examples/RcppGSLExample/man/colNorm.Rd	2010-11-29 17:05:43 UTC (rev 2594)
@@ -30,7 +30,10 @@
 }
 \examples{
   ## see Section 8.4.13 of the GSL manual
+  ## create M as a sum of two outer products
   M <- outer(sin(0:9), rep(1,10), "*") + outer(rep(1, 10), cos(0:9), "*")
   print(colNorm(M))
+  ## same result using just R
+  print(apply(M, 2, function(x) sqrt(sum(x^2))))
 }
 



More information about the Rcpp-commits mailing list