[Rcpp-commits] r1159 - in pkg/RcppArmadillo: . R inst inst/skeleton man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue May 4 11:33:09 CEST 2010


Author: romain
Date: 2010-05-04 11:33:08 +0200 (Tue, 04 May 2010)
New Revision: 1159

Added:
   pkg/RcppArmadillo/R/RcppArmadillo.package.skeleton.R
   pkg/RcppArmadillo/inst/skeleton/
   pkg/RcppArmadillo/inst/skeleton/Makevars
   pkg/RcppArmadillo/inst/skeleton/Makevars.win
   pkg/RcppArmadillo/inst/skeleton/rcpparma_hello_world.R
   pkg/RcppArmadillo/inst/skeleton/rcpparma_hello_world.cpp
   pkg/RcppArmadillo/inst/skeleton/rcpparma_hello_world.h
   pkg/RcppArmadillo/man/RcppArmadillo.package.skeleton.Rd
Removed:
   pkg/RcppArmadillo/README
Modified:
   pkg/RcppArmadillo/DESCRIPTION
   pkg/RcppArmadillo/NAMESPACE
   pkg/RcppArmadillo/NEWS
   pkg/RcppArmadillo/inst/ChangeLog
   pkg/RcppArmadillo/man/RcppArmadillo-package.Rd
Log:
+RcppArmadillo.package.skeleton, move the README to ?RcppArmadillo

Modified: pkg/RcppArmadillo/DESCRIPTION
===================================================================
--- pkg/RcppArmadillo/DESCRIPTION	2010-05-04 08:19:26 UTC (rev 1158)
+++ pkg/RcppArmadillo/DESCRIPTION	2010-05-04 09:33:08 UTC (rev 1159)
@@ -1,7 +1,7 @@
 Package: RcppArmadillo
 Type: Package
-Title: Rcpp/Armadillo translation layer
-Version: 0.1.0.4
+Title: Rcpp/Armadillo bridge
+Version: 0.1.0.5
 Date: $Date$
 Author: Romain Francois, Dirk Eddelbuettel and Doug Bates
 Maintainer: Romain, Dirk and Doug <RcppArmadillo-authors at r-enthusiasts.com>
@@ -27,7 +27,7 @@
  capabilities of the Rcpp package for seamless R and C++ integration/
 License: GPL (>= 2)
 LazyLoad: yes
-Depends: Rcpp (>= 0.7.12.6)
+Depends: R (>= 2.10.0), Rcpp (>= 0.7.12.11)
 LinkingTo: Rcpp
 SystemRequirements: GNU make
 URL: http://arma.sourceforge.net/, http://dirk.eddelbuettel.com/code/rcpp.html, http://romainfrancois.blog.free.fr/index.php?category/R-package/RcppArmadillo

Modified: pkg/RcppArmadillo/NAMESPACE
===================================================================
--- pkg/RcppArmadillo/NAMESPACE	2010-05-04 08:19:26 UTC (rev 1158)
+++ pkg/RcppArmadillo/NAMESPACE	2010-05-04 09:33:08 UTC (rev 1159)
@@ -1,3 +1,4 @@
-useDynLib( RcppArmadillo)
+useDynLib(RcppArmadillo)
 
-export(fastLm)                          # the only visible function here
+export(fastLm)
+export(RcppArmadillo.package.skeleton)

Modified: pkg/RcppArmadillo/NEWS
===================================================================
--- pkg/RcppArmadillo/NEWS	2010-05-04 08:19:26 UTC (rev 1158)
+++ pkg/RcppArmadillo/NEWS	2010-05-04 09:33:08 UTC (rev 1159)
@@ -2,7 +2,11 @@
 
     o   Armadillo sources (using release 0.9.6) are now included in the package
    	using a standardized build suitable for our purposes (not assuming
-   	Boost or Atlas) -- see the new README for details
+   	Boost or Atlas) -- see ?RcppArmadillo for details
+   	
+   	o	New R function RcppArmadillo.package.skeleton, similar to 
+   	Rcpp::Rcpp.package.skeleton, but targetting use of RcppArmadillo
+   	
 
 0.1.0	2010-03-11
 

Added: pkg/RcppArmadillo/R/RcppArmadillo.package.skeleton.R
===================================================================
--- pkg/RcppArmadillo/R/RcppArmadillo.package.skeleton.R	                        (rev 0)
+++ pkg/RcppArmadillo/R/RcppArmadillo.package.skeleton.R	2010-05-04 09:33:08 UTC (rev 1159)
@@ -0,0 +1,123 @@
+## RcppArmadillo.package.skeleton.R: makes a skeleton for a package that wants to use RcppArmadillo
+##
+## Copyright (C)  2010 Dirk Eddelbuettel, Romain Francois and Douglas Bates
+##
+## This file is part of RcppArmadillo.
+##
+## RcppArmadillo is free software: you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 2 of the License, or
+## (at your option) any later version.
+##
+## RcppArmadillo is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with RcppArmadillo.  If not, see <http://www.gnu.org/licenses/>.
+
+RcppArmadillo.package.skeleton <- function(
+	name = "anRpackage", list = character(), environment = .GlobalEnv,
+	path = ".", force = FALSE, namespace = TRUE, 
+	code_files = character(), 
+	example_code = TRUE ){
+	
+	env <- parent.frame(1)
+	
+	if( !length(list) ){
+		fake <- TRUE
+		assign( "Rcpp.fake.fun", function(){}, envir = env )
+	} else {
+		fake <- FALSE
+	}
+	
+	# first let the traditional version do its business
+	call <- match.call()
+	call[[1]] <- as.name("package.skeleton")
+	call[["namespace"]] <- namespace
+	if( "example_code" %in% names( call ) ){
+		# remove the example_code argument
+		call[["example_code"]] <- NULL
+	}
+	if( fake ){
+		call[["list"]] <- "Rcpp.fake.fun"
+	}
+	
+	tryCatch( eval( call, envir = env ), error = function(e){
+		stop( "error while calling `package.skeleton`" )
+	} )
+	
+	message( "\nAdding RcppArmadillo settings" )
+	
+	# now pick things up 
+	root <- file.path( path, name )
+	
+	# Add Rcpp to the DESCRIPTION
+	DESCRIPTION <- file.path( root, "DESCRIPTION" )
+	if( file.exists( DESCRIPTION ) ){
+		x <- cbind( read.dcf( DESCRIPTION ), 
+			"Depends" = sprintf( "Rcpp (>= %s), RcppArmadillo (>= %s) ", 
+				packageDescription("Rcpp")[["Version"]], 
+				packageDescription("RcppArmadillo")[["Version"]]), 
+			"LinkingTo" = "Rcpp, RcppArmadillo", 
+			"SystemRequirements" = "GNU make" )
+		write.dcf( x, file = DESCRIPTION )
+		message( " >> added Depends: Rcpp, RcppArmadillo" )
+		message( " >> added LinkingTo: Rcpp, RcppArmadillo" )
+		message( " >> added SystemRequirements: GNU make" )
+	}
+	
+	# if there is a NAMESPACE, add a useDynLib
+	NAMESPACE <- file.path( root, "NAMESPACE")
+	if( file.exists( NAMESPACE ) ){
+		lines <- readLines( NAMESPACE )
+		if( ! grepl( "useDynLib", lines ) ){
+			lines <- c( sprintf( "useDynLib(%s)", name), lines)
+			writeLines( lines, con = NAMESPACE )
+			message( " >> added useDynLib directive to NAMESPACE" )
+		}
+	}
+	
+	# lay things out in the src directory
+	src <- file.path( root, "src")
+	if( !file.exists( src )){
+		dir.create( src )
+	}
+	skeleton <- system.file( "skeleton", package = "RcppArmadillo" )
+	Makevars <- file.path( src, "Makevars" )
+	if( !file.exists( Makevars ) ){
+		file.copy( file.path( skeleton, "Makevars" ), Makevars )
+		message( " >> added Makevars file with Rcpp settings" )
+	}
+	
+	Makevars.win <- file.path( src, "Makevars.win" )
+	if( !file.exists( Makevars.win ) ){
+		file.copy( file.path( skeleton, "Makevars.win" ), Makevars.win )
+		message( " >> added Makevars.win file with RcppArmadillo settings" )
+	}
+		
+	if( example_code ){
+		header <- readLines( file.path( skeleton, "rcpparma_hello_world.h" ) )
+		header <- gsub( "@PKG@", name, header, fixed = TRUE )
+		writeLines( header , file.path( src, "rcpparma_hello_world.h" ) )
+		message( " >> added example header file using Rcpp/RcppArmadillo")
+		
+		file.copy( file.path( skeleton, "rcpparma_hello_world.cpp" ), src )
+		message( " >> added example src file using armadillo classes")
+		
+		rcode <- readLines( file.path( skeleton, "rcpparma_hello_world.R" ) )
+		rcode <- gsub( "@PKG@", name, rcode, fixed = TRUE )
+		writeLines( rcode , file.path( root, "R", "rcpparma_hello_world.R" ) )
+		message( " >> added example R file calling the C++ example")
+	}
+	if( fake ){
+		rm( "Rcpp.fake.fun", envir = env )
+		unlink( file.path( root, "R"  , "Rcpp.fake.fun.R" ) )
+		unlink( file.path( root, "man", "Rcpp.fake.fun.Rd" ) )
+		
+	}
+	
+	invisible( NULL )
+}
+

Deleted: pkg/RcppArmadillo/README
===================================================================
--- pkg/RcppArmadillo/README	2010-05-04 08:19:26 UTC (rev 1158)
+++ pkg/RcppArmadillo/README	2010-05-04 09:33:08 UTC (rev 1159)
@@ -1,49 +0,0 @@
-
-
-===== typical use =====
-
-to use RcppArmadillo, you need to create a package that : 
-
-- contains the following line in its DESCRIPTION file: 
-
-LinkingTo: Rcpp, RcppArmadillo
-
-- contains a src/Mavevars (and src/Makevars.win) with: 
-
-PKG_LIBS=$(shell Rscript -e "Rcpp:::LdFlags()" ) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
-
-- include the RcppArmadillo.h header. It already includes Rcpp.h so there is no
-need to include Rcpp.h as well
-
-#include <RcppArmadillo.h> 
-
-
-
-===== options : atlas and boost =====
-
-armadillo can optionally use atlas and boost. Please refer to the 
-armadillo documentation http://arma.sourceforge.net/
-
-RcppArmadillo does not force these features. it is up to the third party package 
-to enable these them for their package.
-
-If your package wants to make use of these features, you can add a subset of 
-these lines before #include <RcppArmadillo.h> 
-
-#define ARMA_USE_BOOST
-#define ARMA_USE_BOOST_DATE
-#define ARMA_USE_ATLAS
-
-when you do so, you must make sure that the corresponding features are 
-available, which typically involves writing a configure file. Refer to 
-Writing R Extensions for the procedure.
-
-
-===== questions =====
-
-Please use the Rcpp-devel mailing list on r-forge 
-for questions about RcppArmadillo (subscribe first).
-https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
-
-Questions about armadillo itself should be directed to the armadillo forum
-http://sourceforge.net/apps/phpbb/arma/

Modified: pkg/RcppArmadillo/inst/ChangeLog
===================================================================
--- pkg/RcppArmadillo/inst/ChangeLog	2010-05-04 08:19:26 UTC (rev 1158)
+++ pkg/RcppArmadillo/inst/ChangeLog	2010-05-04 09:33:08 UTC (rev 1159)
@@ -1,3 +1,15 @@
+2010-05-04   Romain Francois <romain at r-enthusiasts.com>
+
+	* R/RcppArmadillo.package.skeleton.R: new package skeleton function
+	similar to Rcpp::Rcpp.package.skeleton but targetting
+	use of RcppArmadillo
+	
+	* README: removed and promoted to additional documentation in ?RcppArmadillo
+
+2010-05-03  Dirk Eddelbuettel  <edd at debian.org>
+
+	* inst/include/* : update to armadillo 0.9.6
+
 2010-04-03  Dirk Eddelbuettel  <edd at debian.org>
 
 	* DESCRIPTION: Remove OS_type restriction now that RcppArmadillo

Added: pkg/RcppArmadillo/inst/skeleton/Makevars
===================================================================
--- pkg/RcppArmadillo/inst/skeleton/Makevars	                        (rev 0)
+++ pkg/RcppArmadillo/inst/skeleton/Makevars	2010-05-04 09:33:08 UTC (rev 1159)
@@ -0,0 +1,3 @@
+## Use the R_HOME indirection to support installations of multiple R version
+PKG_LIBS = $(shell $(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()" ) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
+

Added: pkg/RcppArmadillo/inst/skeleton/Makevars.win
===================================================================
--- pkg/RcppArmadillo/inst/skeleton/Makevars.win	                        (rev 0)
+++ pkg/RcppArmadillo/inst/skeleton/Makevars.win	2010-05-04 09:33:08 UTC (rev 1159)
@@ -0,0 +1,5 @@
+
+## This assume that we can call Rscript to ask Rcpp about its locations
+## Use the R_HOME indirection to support installations of multiple R version
+PKG_LIBS = $(shell Rscript.exe -e "Rcpp:::LdFlags()") $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
+

Added: pkg/RcppArmadillo/inst/skeleton/rcpparma_hello_world.R
===================================================================
--- pkg/RcppArmadillo/inst/skeleton/rcpparma_hello_world.R	                        (rev 0)
+++ pkg/RcppArmadillo/inst/skeleton/rcpparma_hello_world.R	2010-05-04 09:33:08 UTC (rev 1159)
@@ -0,0 +1,5 @@
+
+rcpparma_hello_world <- function(){
+	.Call( "rcpparma_hello_world", PACKAGE = "@PKG@" )
+}
+

Added: pkg/RcppArmadillo/inst/skeleton/rcpparma_hello_world.cpp
===================================================================
--- pkg/RcppArmadillo/inst/skeleton/rcpparma_hello_world.cpp	                        (rev 0)
+++ pkg/RcppArmadillo/inst/skeleton/rcpparma_hello_world.cpp	2010-05-04 09:33:08 UTC (rev 1159)
@@ -0,0 +1,14 @@
+#include "rcpparma_hello_world.h"
+
+using namespace Rcpp ;
+
+SEXP rcpparma_hello_world(){
+	
+	arma::mat m1 = arma::eye<arma::mat>( 3, 3 ) ;
+	arma::mat m2 = arma::eye<arma::mat>( 3, 3 ) ;
+	                     
+	List res ;                                  
+	res["mat+mat"] = m1 + 3 * ( m1 + m2 );
+	return res ;
+}
+

Added: pkg/RcppArmadillo/inst/skeleton/rcpparma_hello_world.h
===================================================================
--- pkg/RcppArmadillo/inst/skeleton/rcpparma_hello_world.h	                        (rev 0)
+++ pkg/RcppArmadillo/inst/skeleton/rcpparma_hello_world.h	2010-05-04 09:33:08 UTC (rev 1159)
@@ -0,0 +1,8 @@
+#ifndef _ at PKG@_RCPP_HELLO_WORLD_H
+#define _ at PKG@_RCPP_HELLO_WORLD_H
+
+#include <RcppArmadillo.h>
+
+RcppExport SEXP rcpparma_hello_world() ;
+
+#endif

Modified: pkg/RcppArmadillo/man/RcppArmadillo-package.Rd
===================================================================
--- pkg/RcppArmadillo/man/RcppArmadillo-package.Rd	2010-05-04 08:19:26 UTC (rev 1158)
+++ pkg/RcppArmadillo/man/RcppArmadillo-package.Rd	2010-05-04 09:33:08 UTC (rev 1159)
@@ -4,11 +4,10 @@
 \alias{RcppArmadilloExample}
 \docType{package}
 \title{
-Rcpp and Armadillon translation layer
+Rcpp/Armadillo bridge
 }
 \description{
-The package eases the integration of Armadillo 
-types with Rcpp
+The package eases the integration of Armadillo types with Rcpp
 }
 \details{
 \tabular{ll}{
@@ -16,15 +15,109 @@
 Type: \tab Package\cr
 Version: \tab 0.0.0\cr
 Date: \tab 2010-02-16\cr
-License: \tab GPL-2\cr
+License: \tab GPL (>= 2)\cr
 LazyLoad: \tab yes\cr
 }
 }
+\section{Armadillo}{
+\code{Armadillo} is a C++ linear algebra library (matrix maths) aiming towards a good
+balance between speed and ease of use. Integer, floating point and complex numbers
+are supported, as well as a subset of trigonometric and statistics functions. 
+Various matrix decompositions are provided through optional integration with 
+LAPACK and ATLAS libraries.
+
+A delayed evaluation approach is employed (during compile time) to combine several 
+operations into one and reduce (or eliminate) the need for temporaries. 
+This is accomplished through recursive templates and template meta-programming.
+
+This library is useful if C++ has been decided as the language of choice 
+(due to speed and/or integration capabilities), rather than another language 
+like Matlab or Octave. It is distributed under a license that is useful in 
+both open-source and commercial contexts.
+
+Armadillo is primarily developed at NICTA (Australia), 
+with contributions from around the world.	
+}
+
+\section{RcppArmadillo}{
+\code{RcppArmadillo} acts as a bridge between \code{Rcpp} and \code{Armadillo}, 
+allowing the programmer to write code using armadillo classes that integrate
+seemlessly with \code{Rcpp}. 
+}
+
+\section{Using RcppArmadillo}{
+The simplest way to get started is to create a skeleton of a package
+using \code{RcppArmadillo}, this is done by the \code{\link{RcppArmadillo.package.skeleton}}
+function. 
+
+The important steps are
+\itemize{
+	\item Include the \code{RcppArmadillo.h} header file, which also includes
+	armadillo.h
+	\item Depend and link to Rcpp and RcppArmadillo by adding these lines to 
+	the DESCRIPTION file: 
+
+\Sexpr[results=rd, echo=FALSE, stage=render]{
+paste( 
+	"\\\\preformatted{Depends: Rcpp (>=", 
+	packageDescription("Rcpp")[["Version"]] ,
+	"), RcppArmadillo (>= ",
+	packageDescription("RcppArmadillo")[["Version"]] ,
+	")\\nLinkingTo: Rcpp, RcppArmadillo\\n}", sep = "" ) 	
+}
+
+	\item Link against the Rcpp, blas and lapack libraries, by adding this line
+	in the Makevars
+
+\preformatted{PKG_LIBS = $(shell $(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()" ) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) }
+
+and this line to the Makevars.win: 
+\preformatted{PKG_LIBS = $(shell Rscript.exe -e "Rcpp:::LdFlags()") $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) }
+
+}
+}
+
+\section{Options: ATLAS and Boost}{
+Armadillo can optionally use atlas and boost. Please refer to the 
+Armadillo documentation \url{http://arma.sourceforge.net/}
+
+\code{RcppArmadillo} does not force these features. it is up to the third party package 
+to enable these them for their package. If your package wants to make use of 
+these features, you can add a subset of 
+these lines before \code{#include <RcppArmadillo.h>}
+
+\preformatted{
+#define ARMA_USE_BOOST
+#define ARMA_USE_BOOST_DATE
+#define ARMA_USE_ATLAS
+}
+
+when you do so, you must make sure that the corresponding features are 
+available, which typically involves writing a configure file. Refer to 
+Writing R Extensions for the procedure.
+	
+}
+
+\section{Support}{
+Please use the Rcpp-devel mailing list on r-forge 
+for questions about RcppArmadillo (subscribe first).
+\url{https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel}
+
+Questions about armadillo itself should be directed to the armadillo forum
+\url{http://sourceforge.net/apps/phpbb/arma/}	
+}
+
+
 \author{
-Maintainer: Dirk and Romain <RomainAndDirk at r-enthusiasts.com>
+Romain Francois, Dirk Eddelbuettel and Doug Bates
+	
+Maintainer: Romain, Dirk and Doug <RcppArmadillo-authors at r-enthusiasts.com>
 }
 \references{
 Armadillo project: \url{http://arma.sourceforge.net/}
 }
 \keyword{ package }
+\keyword{ programming }
+\keyword{ interface }
 
+

Added: pkg/RcppArmadillo/man/RcppArmadillo.package.skeleton.Rd
===================================================================
--- pkg/RcppArmadillo/man/RcppArmadillo.package.skeleton.Rd	                        (rev 0)
+++ pkg/RcppArmadillo/man/RcppArmadillo.package.skeleton.Rd	2010-05-04 09:33:08 UTC (rev 1159)
@@ -0,0 +1,69 @@
+\name{RcppArmadillo.package.skeleton}
+\alias{RcppArmadillo.package.skeleton}
+\title{
+Create a skeleton for a new package that intends to use RcppArmadillo
+}
+\description{
+	\code{RcppArmadillo.package.skeleton} automates the creation of 
+	a new source package that intends to use features of RcppArmadilo. 
+	
+	It is based on the \link[utils]{package.skeleton} function
+	which it executes first.
+}
+\usage{
+RcppArmadillo.package.skeleton(name = "anRpackage", list = character(), 
+	environment = .GlobalEnv, path = ".", force = FALSE, namespace = TRUE, 
+	code_files = character(), example_code = TRUE)
+}
+\arguments{
+	\item{name}{See \link[utils]{package.skeleton}}
+	\item{list}{See \link[utils]{package.skeleton}}
+	\item{environment}{See \link[utils]{package.skeleton}}
+	\item{path}{See \link[utils]{package.skeleton}}
+	\item{force}{See \link[utils]{package.skeleton}}
+	\item{namespace}{See \link[utils]{package.skeleton}}
+	\item{code_files}{See \link[utils]{package.skeleton}}
+	\item{example_code}{If TRUE, example c++ code using RcppArmadillo is added to the package}
+}
+\details{
+	In addition to \link[utils]{package.skeleton} : 
+	
+	The \samp{DESCRIPTION} file gains a Depends line requesting that 
+	the package depends on Rcpp and RcppArmadillo and 
+	a LinkingTo line so that the package finds Rcpp and RcppArmadillo header files.
+	
+	The \samp{NAMESPACE}, if any, gains a \code{useDynLib} directive.
+	
+	The \samp{src} directory is created if it does not exists and 
+	a \samp{Makevars} file is added setting the environment variable
+	\samp{PKG_LIBS} to accomodate the necessary flags
+	to link with the Rcpp library. 
+	
+	If the \code{example_code} argument is set to \code{TRUE}, 
+	example files \samp{rcpparma_hello_world.h} and \samp{rcpparma_hello_world.cpp}
+	are also created in the \samp{src}. An R file \samp{rcpparma_hello_world.R} is 
+	expanded in the \samp{R} directory, the \code{rcpparma_hello_world} function
+	defined in this files makes use of the C++ function \samp{rcpparma_hello_world}
+	defined in the C++ file. These files are given as an example and should 
+	eventually by removed from the generated package.
+}
+\value{
+Nothing, used for its side effects
+}
+\seealso{
+\link[utils]{package.skeleton}
+}
+\references{
+Read the \emph{Writing R Extensions} manual for more details.
+
+Once you have created a \emph{source} package you need to install it:
+see the \emph{R Installation and Administration} manual,
+\code{\link{INSTALL}} and \code{\link{install.packages}}.
+}
+\examples{
+\dontrun{
+RcppArmadillo.package.skeleton( "foobar" )
+}
+}
+\keyword{ programming }
+



More information about the Rcpp-commits mailing list