[Rcpp-commits] r703 - in pkg/RcppArmadillo: . R man src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Feb 16 18:26:43 CET 2010


Author: edd
Date: 2010-02-16 18:26:43 +0100 (Tue, 16 Feb 2010)
New Revision: 703

Added:
   pkg/RcppArmadillo/DESCRIPTION
   pkg/RcppArmadillo/NAMESPACE
   pkg/RcppArmadillo/R/
   pkg/RcppArmadillo/R/zzz.R
   pkg/RcppArmadillo/man/
   pkg/RcppArmadillo/man/RcppArmadillo-package.Rd
   pkg/RcppArmadillo/src/
   pkg/RcppArmadillo/src/Makevars
   pkg/RcppArmadillo/src/Makevars.win
   pkg/RcppArmadillo/src/RcppArmadillo.cpp
   pkg/RcppArmadillo/src/RcppArmadillo.h
Log:
committing 0.0.0 tarball by Romain

Added: pkg/RcppArmadillo/DESCRIPTION
===================================================================
--- pkg/RcppArmadillo/DESCRIPTION	                        (rev 0)
+++ pkg/RcppArmadillo/DESCRIPTION	2010-02-16 17:26:43 UTC (rev 703)
@@ -0,0 +1,13 @@
+Package: RcppArmadillo
+Type: Package
+Title: Rcpp/Armadillo translation layer
+Version: 0.0.0
+Date: 2010-02-16
+Author: Romain Francois and Dirk Eddelbuettel
+Maintainer: RcppArmadillo developpers <rcpparmadillo at r-enthusiasts.com>
+Description: The package eases integration of armadillo types with Rcpp
+License: LGPL-3
+LazyLoad: yes
+Depends: Rcpp (>= 0.7.7)
+SystemRequirements: armadillo
+Packaged: 2010-02-16 14:17:09 UTC; romain

Added: pkg/RcppArmadillo/NAMESPACE
===================================================================
--- pkg/RcppArmadillo/NAMESPACE	                        (rev 0)
+++ pkg/RcppArmadillo/NAMESPACE	2010-02-16 17:26:43 UTC (rev 703)
@@ -0,0 +1,2 @@
+useDynLib(RcppArmadillo)
+

Added: pkg/RcppArmadillo/R/zzz.R
===================================================================
--- pkg/RcppArmadillo/R/zzz.R	                        (rev 0)
+++ pkg/RcppArmadillo/R/zzz.R	2010-02-16 17:26:43 UTC (rev 703)
@@ -0,0 +1,5 @@
+
+example <- function(){
+	str( .Call( "RcppArmadilloExample", PACKAGE = "RcppArmadillo" ) ) 
+}
+

Added: pkg/RcppArmadillo/man/RcppArmadillo-package.Rd
===================================================================
--- pkg/RcppArmadillo/man/RcppArmadillo-package.Rd	                        (rev 0)
+++ pkg/RcppArmadillo/man/RcppArmadillo-package.Rd	2010-02-16 17:26:43 UTC (rev 703)
@@ -0,0 +1,29 @@
+\name{RcppArmadillo-package}
+\alias{RcppArmadillo-package}
+\alias{RcppArmadillo}
+\docType{package}
+\title{
+Rcpp and Armadillon translation layer
+}
+\description{
+The package eases the integration of Armadillo 
+types with Rcpp
+}
+\details{
+\tabular{ll}{
+Package: \tab RcppArmadillo\cr
+Type: \tab Package\cr
+Version: \tab 0.0.0\cr
+Date: \tab 2010-02-16\cr
+License: \tab LGPL-3\cr
+LazyLoad: \tab yes\cr
+}
+}
+\author{
+Maintainer: RcppArmadillo developpers <RcppArmadillo at r-enthusiasts.com>
+}
+\references{
+Armadillo project: \url{http://arma.sourceforge.net/}
+}
+\keyword{ package }
+

Added: pkg/RcppArmadillo/src/Makevars
===================================================================
--- pkg/RcppArmadillo/src/Makevars	                        (rev 0)
+++ pkg/RcppArmadillo/src/Makevars	2010-02-16 17:26:43 UTC (rev 703)
@@ -0,0 +1,6 @@
+## Use the R_HOME indirection to support installations of multiple R version
+PKG_CPPFLAGS=$(shell $(R_HOME)/bin/Rscript -e "Rcpp:::CxxFlags()" )
+PKG_LIBS = $(shell $(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()" )
+## Uncomment this if you want to use C++0x features -- which are not currently portable
+## CLINK_CPPFLAGS=$(shell Rscript -e "Rcpp:::Cxx0xFlags()" )
+

Added: pkg/RcppArmadillo/src/Makevars.win
===================================================================
--- pkg/RcppArmadillo/src/Makevars.win	                        (rev 0)
+++ pkg/RcppArmadillo/src/Makevars.win	2010-02-16 17:26:43 UTC (rev 703)
@@ -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 = `$(R_HOME)/bin/Rscript -e 'Rcpp:::LdFlags()'`
+PKG_CPPFLAGS = `$(R_HOME)/bin/Rscript -e 'Rcpp:::CxxFlags()'`

Added: pkg/RcppArmadillo/src/RcppArmadillo.cpp
===================================================================
--- pkg/RcppArmadillo/src/RcppArmadillo.cpp	                        (rev 0)
+++ pkg/RcppArmadillo/src/RcppArmadillo.cpp	2010-02-16 17:26:43 UTC (rev 703)
@@ -0,0 +1,25 @@
+#include "RcppArmadillo.h"
+
+SEXP RcppArmadilloExample(){
+	using namespace Rcpp ;
+	using namespace arma ;
+	
+	List output(4); 
+	
+	imat x1 = eye<imat>( 3,3 ) ;
+	x1.swap_rows(0,1)  ;
+	output[0] = x1 ;
+	
+	mat x2 = eye<mat>( 3,3 ) ;
+	x2.swap_rows(0,1)  ;
+	output[1] = x2 ;
+	
+	colvec y1 = zeros<colvec>(5,1);
+	output[2] = y1  ;
+	
+	rowvec y2 = zeros<mat>(1,5);
+	output[3] = y2  ;
+	
+	return output ;
+}
+

Added: pkg/RcppArmadillo/src/RcppArmadillo.h
===================================================================
--- pkg/RcppArmadillo/src/RcppArmadillo.h	                        (rev 0)
+++ pkg/RcppArmadillo/src/RcppArmadillo.h	2010-02-16 17:26:43 UTC (rev 703)
@@ -0,0 +1,57 @@
+#ifndef RcppArmadillo__RcppArmadillo__h
+#define RcppArmadillo__RcppArmadillo__h
+
+#include <RcppCommon.h>
+#include <armadillo>
+
+/* forward declarations */
+namespace Rcpp{
+	template <typename T> SEXP wrap ( const arma::Mat<T>& ) ;
+	template <typename T> SEXP wrap ( const arma::Row<T>& ) ;
+	template <typename T> SEXP wrap ( const arma::Col<T>& ) ;
+}
+
+#include <Rcpp.h>
+
+RcppExport SEXP RcppArmadilloExample() ;
+
+namespace Rcpp{
+
+/* wrap */
+
+template <typename T> SEXP wrap ( const arma::Mat<T>& mat ){
+	SimpleVector< traits::r_sexptype_traits<T>::rtype > vec( 
+		Dimension( mat.n_rows, mat.n_cols ) );
+	int n = mat.n_elem ;
+	for( int i=0; i<n; i++){
+		vec[i] = mat[i] ;
+	}
+	return vec ; 
+} ;
+
+template <typename T> SEXP wrap( const arma::Col<T>& column ){
+	int n = column.n_rows ;
+	SimpleVector< traits::r_sexptype_traits<T>::rtype > vec( 
+		Dimension( n, 1 ) );
+	for( int i=0; i<n; i++){
+		vec[i] = column[i] ;
+	}
+	return vec ;
+}
+
+template <typename T> SEXP wrap( const arma::Row<T>& row ){
+	int n = row.n_cols ;
+	SimpleVector< traits::r_sexptype_traits<T>::rtype > vec( 
+		Dimension( 1, n ) );
+	for( int i=0; i<n; i++){
+		vec[i] = row[i] ;
+	}
+	return vec ;
+}
+
+/* as */
+
+} // namespace Rcpp
+
+#endif
+



More information about the Rcpp-commits mailing list