[Rcpp-commits] r3210 - in pkg/RcppEigen: . inst/doc inst/include/Eigen/src/Cholesky inst/include/Eigen/src/Core inst/include/Eigen/src/Eigen2Support/Geometry inst/include/Eigen/src/SVD
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Oct 20 17:15:52 CEST 2011
Author: dmbates
Date: 2011-10-20 17:15:52 +0200 (Thu, 20 Oct 2011)
New Revision: 3210
Added:
pkg/RcppEigen/inst/doc/Rcpp.bib
pkg/RcppEigen/inst/doc/RcppEigen-Intro.Rnw
Modified:
pkg/RcppEigen/DESCRIPTION
pkg/RcppEigen/NAMESPACE
pkg/RcppEigen/inst/include/Eigen/src/Cholesky/LDLT.h
pkg/RcppEigen/inst/include/Eigen/src/Core/Fuzzy.h
pkg/RcppEigen/inst/include/Eigen/src/Core/Map.h
pkg/RcppEigen/inst/include/Eigen/src/Core/PlainObjectBase.h
pkg/RcppEigen/inst/include/Eigen/src/Core/ProductBase.h
pkg/RcppEigen/inst/include/Eigen/src/Eigen2Support/Geometry/AlignedBox.h
pkg/RcppEigen/inst/include/Eigen/src/SVD/JacobiSVD.h
Log:
Update to Eigen 3.0.3, add first draft of introduction.
Modified: pkg/RcppEigen/DESCRIPTION
===================================================================
--- pkg/RcppEigen/DESCRIPTION 2011-10-02 03:59:56 UTC (rev 3209)
+++ pkg/RcppEigen/DESCRIPTION 2011-10-20 15:15:52 UTC (rev 3210)
@@ -1,8 +1,8 @@
Package: RcppEigen
Type: Package
Title: Rcpp integration for the Eigen templated linear algebra library.
-Version: 0.1.2
-Date: 2011-09-12
+Version: 0.1.3
+Date: 2011-10-22
Author: Douglas Bates, Romain Francois and Dirk Eddelbuettel
Maintainer: Douglas Bates, Romain Francois and Dirk Eddelbuettel <RcppArmadillo-authors at r-enthusiasts.com>
Description: R and Eigen integration using Rcpp.
Modified: pkg/RcppEigen/NAMESPACE
===================================================================
--- pkg/RcppEigen/NAMESPACE 2011-10-02 03:59:56 UTC (rev 3209)
+++ pkg/RcppEigen/NAMESPACE 2011-10-20 15:15:52 UTC (rev 3210)
@@ -1,8 +1,6 @@
useDynLib(RcppEigen)
-#import(Rcpp)
importClassesFrom("Matrix"
- , ddiMatrix
, dgCMatrix
, dgeMatrix
, dsCMatrix
Added: pkg/RcppEigen/inst/doc/Rcpp.bib
===================================================================
--- pkg/RcppEigen/inst/doc/Rcpp.bib (rev 0)
+++ pkg/RcppEigen/inst/doc/Rcpp.bib 2011-10-20 15:15:52 UTC (rev 3210)
@@ -0,0 +1,456 @@
+ at String{CRAN = "http://CRAN.R-Project.org/" }
+ at String{manuals = CRAN # "doc/manuals/" }
+ at String{RCoreTeam = "{R Development Core Team}" }
+ at String{RFoundation = "R Foundation for Statistical Computing" }
+ at String{R-Forge = "http://R-Forge.R-Project.org/" }
+
+ at manual{Abrahams+Grosse-Kunstleve:2003:Boost.Python,
+ author = { David Abrahams and Ralf W. Grosse-Kunstleve },
+ organization = "Boost Consulting",
+ title = "Building Hybrid Systems with Boost.Python",
+ year = 2003,
+ url = "http://www.boostpro.com/writing/bpl.pdf"
+}
+
+ at Book{Abrahams+Gurtovoy:2004:TemplateMetaprogramming,
+ author = {David Abrahams and Aleksey Gurtovoy},
+ title = {{C++} {T}emplate {M}etaprogramming: Concepts, Tools
+ and Techniques from {B}oost and Beyond},
+ publisher = {Addison-Wesley},
+ year = 2004,
+ address = {Boston}
+}
+
+ at Manual{Armstrong:2009:RAbstraction,
+ title = {{RAbstraction}: {C++} abstraction for {R} objects},
+ author = {Whit Armstrong},
+ year = 2009,
+ note = {Code repository last updated 2009-07-22.},
+ url = {http://github.com/armstrtw/rabstraction}
+}
+
+ at Manual{Armstrong:2009:RObjects,
+ title = {{RObjects}: {C++} wrapper for R objects (a better
+ implementation of {RAbstraction}},
+ author = {Whit Armstrong},
+ year = 2009,
+ note = {Code repository last updated 2009-11-28.},
+ url = {http://github.com/armstrtw/RObjects}
+}
+
+ at InProceedings{Bates+DebRoy:2001:C++Classes,
+ author = {Douglas M. Bates and Saikat DebRoy},
+ title = {{C++} Classes for {R} Objects},
+ booktitle = {Proceedings of the 2nd International Workshop on Distributed
+ Statistical Computing, March 15--17, 2001, Technische
+ Universit\"at Wien, Vienna, Austria},
+ editor = {Kurt Hornik and Friedrich Leisch},
+ year = {2001},
+ url = {http://www.ci.tuwien.ac.at/Conferences/DSC-2001/Proceedings/},
+ note = {ISSN 1609-395X}
+}
+
+
+ at Misc{Brokken:2011:Cpp,
+ author = {Frank B. Brokken},
+ title = {C++ Annotations},
+ howpublished = {Electronic book, University of Groningen},
+ year = 2011,
+ url = {http://www.icce.rug.nl/documents/cplusplus/}
+}
+
+ at Book{Chambers:2008:SoDA,
+ author = {John M. Chambers},
+ title = {Software for Data Analysis: Programming with {R}},
+ publisher = {Springer-Verlag},
+ year = 2008,
+ series = {Statistics and Computing},
+ address = {Heidelberg},
+ note = {{ISBN} 978-0-387-75935-7}
+}
+
+ at Manual{CRAN:RInside,
+ title = {RInside: C++ classes to embed R in C++ applications},
+ author = {Dirk Eddelbuettel and Romain Fran\c{c}ois},
+ year = 2010,
+ note = {R package version 0.2.3},
+ url = CRAN # "package=RInside"
+}
+
+ at Manual{CRAN:RProtoBuf,
+ title = {RProtoBuf: R Interface to the Protocol Buffers API},
+ author = {Romain Fran\c{c}ois and Dirk Eddelbuettel},
+ year = 2011,
+ note = {R package version 0.2.3},
+ url = CRAN # "package=RProtoBuf"
+}
+
+ at Manual{CRAN:RQuantLib,
+ title = {RQuantLib: {R} interface to the {QuantLib} library},
+ author = {Dirk Eddelbuettel and Khanh Nguyen},
+ year = 2011,
+ note = {R package version 0.3.6},
+ url = CRAN # "package=RQuantLib"
+}
+
+ at Article{JSS:Rcpp,
+ title = {{Rcpp}: Seamless {R} and {C++} Integration},
+ author = {Dirk Eddelbuettel and Romain Fran\c{c}ois},
+ journal = {Journal of Statistical Software},
+ year = 2011,
+ volume = 40,
+ number = 8,
+ pages = {1--18},
+ url = {http://www.jstatsoft.org/v40/i08/},
+}
+
+ at Manual{CRAN:Rcpp,
+ title = {{Rcpp}: Seamless {R} and {C++} Integration},
+ author = {Dirk Eddelbuettel and Romain Fran\c{c}ois},
+ year = 2011,
+ note = {R package version 0.9.4},
+ url = CRAN # "package=Rcpp"
+}
+
+ at Manual{CRAN:RcppArmadillo,
+ title = {RcppArmadillo: Rcpp integration for Armadillo
+ templated linear algebra library},
+ author = {Romain Fran\c{c}ois and Dirk Eddelbuettel and
+ Douglas Bates},
+ year = 2011,
+ note = {R package version 0.2.18},
+ url = CRAN # "package=RcppArmadillo"
+}
+
+ at Manual{CRAN:RcppClassic,
+ title = {RcppClassic: Deprecated 'classic' Rcpp API},
+ author = {Dirk Eddelbuettel and Romain Fran\c{c}ois},
+ year = 2011,
+ note = {R package version 0.9.1},
+ url = CRAN # "package=RcppClassic"
+}
+
+ at Manual{CRAN:RcppDE,
+ title = {RcppDE: Global optimization by differential evolution in C++},
+ author = {Dirk Eddelbuettel},
+ year = 2010,
+ note = {R package version 0.1.0},
+ url = CRAN # "package=RcppDE"
+}
+
+ at Manual{CRAN:RcppExamples,
+ title = {RcppExamples: Examples using {Rcpp} to interface {R}
+ and {C++}},
+ author = {Dirk Eddelbuettel and Romain Fran\c{c}ois},
+ year = 2010,
+ note = {R package version 0.1.2},
+ url = CRAN # "package=RcppExamples"
+}
+
+ at Manual{CRAN:RcppGSL,
+ title = {RcppGSL: Rcpp integration for GNU GSL vectors and matrices},
+ author = {Romain Fran\c{c}ois and Dirk Eddelbuettel},
+ year = 2011,
+ note = {R package version 0.1.1},
+ url = CRAN # "package=RcppGSL"
+}
+
+ at Manual{CRAN:Rserve,
+ title = {Rserve: Binary R server},
+ author = {Simon Urbanek},
+ year = 2011,
+ note = {R package version 0.6-3},
+ url = CRAN # "package=Rserve"
+}
+
+ at Manual{CRAN:cxxPack,
+ title = {cxxpack: {R/C++} Tools for Literate Statistical
+ Practice},
+ author = {Dominick Samperi},
+ year = 2010,
+ note = {R package version 7.0.6},
+ url = CRAN # "package=cxxPack"
+}
+
+ at Manual{CRAN:highlight,
+ title = {highlight: Syntax highlighter},
+ author = {Romain Fran\c{c}ois},
+ year = 2010,
+ note = {R package version 0.2-5},
+ url = CRAN # "package=highlight"
+}
+
+ at Manual{CRAN:inline,
+ title = {inline: Inline C, C++, Fortran function calls from
+ R},
+ author = {Oleg Sklyar and Duncan Murdoch and Mike Smith and
+ Dirk Eddelbuettel and Romain Fran\c{c}ois},
+ year = 2010,
+ note = {R package version 0.3.8},
+ url = CRAN # "package=inline"
+}
+
+ at Manual{CRAN:minqa,
+ title = {minqa: Derivative-free optimization algorithms by
+ quadratic approximation},
+ author = {Douglas Bates and Katharine M. Mullen and John
+ C. Nash and Ravi Varadhan},
+ year = 2011,
+ note = {R package version 1.1.15},
+ url = CRAN # "package=minqa"
+}
+
+ at Article{Gropp+Lusk+Doss+Skjellum:1996:MPI,
+ author = {William Gropp and Ewing Lusk and Nathan Doss and Anthony Skjellum},
+ title = {A high-performance, portable implementation of the {MPI} message passing interface standard},
+ journal = {Parallel Computing},
+ year = 1996,
+ url = {http://dx.doi.org/10.1016/0167-8191(96)00024-5},
+ volume = 22,
+ number = 6,
+ pages = {789--828}
+}
+
+ at Book{Gropp+Lusk+Skjellum:1999:MPI,
+ author = {William Gropp and Ewing Lusk and Anthony Skjellum},
+ title = {Using {MPI}: Portable Parallel Programming with the Message Passing Interface},
+ publisher = {MIT Press},
+ year = 1999,
+ series = {Scientific and Engineering Computation Series},
+ edition = {2nd},
+ month = {November},
+ note = {{ISBN} 978-0-262-57132-6}}
+
+ at Manual{GSL,
+ title = {{GNU} {S}cientific {L}ibrary {R}eference {M}anual},
+ author = {Mark Galassi and Jim Davies and James Theiler and Brian Gough and Gerard Jungman and Patrick Alken and Michael Booth and Fabrice Rossi},
+ year = {2010},
+ edition = {3rd},
+ note = {Version 1.14. {ISBN} 0954612078},
+ url = {http://www.gnu.org/software/gsl}
+}
+
+ at Unpublished{Java+Gaile+Manly:2007:RCpp,
+ author = {James J. Java and Daniel P. Gaile and Kenneth
+ E. Manly},
+ title = {{R/Cpp}: Interface Classes to Simplify Using {R}
+ Objects in {C++} Extensions},
+ note = {Unpublished manuscript, University at Buffalo},
+ url =
+ {http://sphhp.buffalo.edu/biostat/research/techreports/UB_Biostatistics_TR0702.pdf},
+ month = {July},
+ year = 2007
+}
+
+ at InProceedings{Leisch:2008:Tutorial,
+ author = {Friedrich Leisch},
+ title = {Tutorial on {C}reating \proglang{R} {P}ackages},
+ booktitle = {COMPSTAT 2008 -- Proceedings in Computational
+ Statistics},
+ year = 2008,
+ editor = {Paula Brito},
+ address = {Heidelberg},
+ publisher = {Physica Verlag},
+ url = CRAN # "doc/contrib/Leisch-CreatingPackages.pdf"
+}
+
+ at Manual{Liang:2008:rcppbind,
+ title = {rcppbind: {A} template library for R/C++ developers},
+ author = {Gang Liang},
+ year = 2008,
+ note = {R package version 1.0},
+ url = R-Forge # "projects/rcppbind"
+}
+
+ at Book{Lippman+Lajoie+Moo:2005:Cpp_Primer,
+ author = {Stanley B. Lippman and Jos\'{e}e Lajoie and Barbara E. Moo},
+ title = {The C++ Primer},
+ publisher = {Addison-Wesley},
+ address = {Boston},
+ year = 2005,
+ edition = {4th}
+}
+
+ at book{Meyers:1995:MoreEffectiveC++,
+ author = {Scott Meyers},
+ title = {More Effective C++: 35 New Ways to Improve Your
+ Programs and Designs},
+ year = 1995,
+ note = {{ISBN} 020163371X},
+ publisher = {Addison-Wesley},
+ address = {Boston}
+}
+
+ at book{Meyers:2001:EffectiveSTL,
+ author = {Scott Meyers},
+ title = {Effective STL: 50 specific ways to improve your use
+ of the standard template library},
+ year = 2001,
+ note = {{ISBN} 0-201-74962-9},
+ publisher = {Addison-Wesley},
+ address = {Essex}
+}
+
+ at book{Meyers:2005:EffectiveC++,
+ author = {Scott Meyers},
+ title = {Effective C++: 55 Specific Ways to Improve Your
+ Programs and Designs},
+ year = 2005,
+ note = {{ISBN} 978-0321334879},
+ publisher = {Addison-Wesley},
+ address = {Boston},
+ edition = {3rd},
+}
+
+ at Book{Plauger+Et+Al:2000:STL,
+ author = {P.J. Plauger and Alexander Stepanov and Meng Lee and
+ David R. Musser},
+ title = {The {C++} Standard Template Library},
+ publisher = {Prentice Hall PTR},
+ year = 2000,
+ note = {{ISBN} 978-0134376332},
+}
+
+ at manual{R:Administration,
+ author = RCoreTeam,
+ organization = RFoundation,
+ address = {Vienna, Austria},
+ year = 2010,
+ title = "R Installation and Administration",
+ note = {{ISBN} 3-900051-09-7},
+ url = manuals # "R-admin.html"
+}
+
+ at manual{R:Extensions,
+ author = RCoreTeam,
+ organization = RFoundation,
+ address = {Vienna, Austria},
+ year = 2011,
+ title = "Writing R extensions",
+ note = {{ISBN} 3-900051-11-9},
+ url = manuals # "R-exts.html"
+}
+
+ at manual{R:Internals,
+ author = RCoreTeam,
+ organization = RFoundation,
+ address = {Vienna, Austria},
+ year = 2011,
+ title = "R internals",
+ note = {{ISBN} 3-900051-14-3},
+ url = manuals # "R-ints.html"
+}
+
+ at manual{R:Main,
+ title = {R: A Language and Environment for Statistical
+ Computing},
+ author = RCoreTeam,
+ organization = RFoundation,
+ address = {Vienna, Austria},
+ year = 2011,
+ note = {{ISBN} 3-900051-07-0},
+ url = {http://www.R-project.org/},
+}
+
+ at manual{R:Language,
+ author = RCoreTeam,
+ organization = RFoundation,
+ address = {Vienna, Austria},
+ year = 2011,
+ title = "R language",
+ note = {{ISBN} 3-900051-13-5},
+ url = manuals # "R-lang.html"
+}
+
+ at InProceedings{Runnalls:2009:CXXR,
+ author = {Andrew Runnalls},
+ title = {Aspects of {CXXR} internals},
+ booktitle = {Directions in Statistical Computing},
+ address = {University of Copenhagen, Denmark},
+ year = 2009
+}
+
+ at Manual{Samperi:2009:RcppTemplate,
+ title = {RcppTemplate: Rcpp {R/C++} Object Mapping Library
+ and Package Template},
+ author = {Dominick Samperi},
+ year = 2009,
+ note = {(Archived) R package version 6.1},
+ url = CRAN # "/src/contrib/Archive/RcppTemplate"
+}
+
+ at TechReport{Sanderson:2010:Armadillo,
+ author = {Conrad Sanderson},
+ title = {{Armadillo}: {An} open source {C++} Algebra Library
+ for Fast Prototyping and Computationally Intensive
+ Experiments },
+ institution = {{NICTA}},
+ year = 2010,
+ url = "http://arma.sf.net"
+}
+
+ at Book{Stroustrup:1997:Cpp,
+ author = {Bjarne Stroustrup},
+ title = {The C++ Programming Language},
+ publisher = {Addison-Wesley},
+ address = {Boston},
+ year = 1997,
+ edition = {3rd}
+}
+
+ at Article{TempleLang:2009:ModestProposal,
+ author = {Duncan {Temple Lang}},
+ title = {A modest proposal: an approach to making the
+ internal {R} system extensible},
+ journal = {Computational Statistics},
+ year = 2009,
+ volume = 24,
+ number = 2,
+ pages = {271-281},
+ month = {May}
+}
+
+ at Article{TempleLang:2009:RGCCTranslationUnit,
+ author = {Duncan {Temple Lang}},
+ title = {Working with meta-data from {C/C++} code in {R}: the
+ {RGCCTranslationUnit} package},
+ journal = {Computational Statistics},
+ year = 2009,
+ volume = 24,
+ number = 2,
+ pages = {283-293},
+ month = {May}
+}
+
+ at InProceedings{Urbanek:2003:Rserve,
+ author = {Simon Urbanek},
+ title = {{Rserve}: A Fast Way to Provide {R} Functionality to
+ Applications},
+ booktitle = {Proceedings of the 3rd International Workshop on Distributed
+ Statistical Computing, Vienna, Austria},
+ editor = {Kurt Hornik and Friedrich Leisch and Achim Zeileis},
+ year = {2003},
+ url = {http://www.ci.tuwien.ac.at/Conferences/DSC-2003/Proceedings/},
+ note = {{ISSN 1609-395X}}
+}
+
+ at Book{Vandevoorde+Josuttis:2003:Templates,
+ author = {David Vandevoorde and Nicolai M. Josuttis},
+ title = {{C++} {T}emplates: The Complete Guide},
+ publisher = {Addison-Wesley},
+ year = 2003,
+ address = {Boston}
+}
+
+ at inproceedings{Veldhuizen:1998:Blitz,
+ author = {Todd L. Veldhuizen},
+ title = {Arrays in {Blitz++}},
+ booktitle = {ISCOPE '98: Proceedings of the Second International
+ Symposium on Computing in Object-Oriented Parallel
+ Environments},
+ note = {{ISBN} 3-540-65387-2},
+ year = 1998,
+ pages = {223--230},
+ publisher = {Springer-Verlag},
+ address = {London},
+}
Added: pkg/RcppEigen/inst/doc/RcppEigen-Intro.Rnw
===================================================================
--- pkg/RcppEigen/inst/doc/RcppEigen-Intro.Rnw (rev 0)
+++ pkg/RcppEigen/inst/doc/RcppEigen-Intro.Rnw 2011-10-20 15:15:52 UTC (rev 3210)
@@ -0,0 +1,551 @@
+\documentclass[10pt]{article}
+%\VignetteIndexEntry{RcppEigen-intro}
+\usepackage{vmargin}
+\setmargrb{0.75in}{0.75in}{0.75in}{0.75in}
+
+\usepackage{color, alltt, bm}
+\usepackage[authoryear,round,longnamesfirst]{natbib}
+\usepackage[colorlinks]{hyperref}
+\definecolor{link}{rgb}{0,0,0.3} %% next few lines courtesy of RJournal.sty
+\hypersetup{
+ colorlinks,%
+ citecolor=link,%
+ filecolor=link,%
+ linkcolor=link,%
+ urlcolor=link
+}
+
+\newcommand{\proglang}[1]{\textsf{#1}}
+\newcommand{\pkg}[1]{{\fontseries{b}\selectfont #1}}
+\newcommand{\code}[1]{\texttt{#1}}
+
+%% defined as a stop-gap measure til interaction with highlight is sorted out
+\newcommand{\hlstd}[1]{\textcolor[rgb]{0,0,0}{#1}}
+\newcommand{\hlnum}[1]{\textcolor[rgb]{0.69,0.49,0}{#1}}
+\newcommand{\hlesc}[1]{\textcolor[rgb]{1,0,1}{#1}}
+\newcommand{\hlstr}[1]{\textcolor[rgb]{0.75,0.01,0.01}{#1}}
+\newcommand{\hlpps}[1]{\textcolor[rgb]{0.51,0.51,0}{#1}}
+\newcommand{\hlslc}[1]{\textcolor[rgb]{0.51,0.51,0.51}{\it{#1}}}
+\newcommand{\hlcom}[1]{\textcolor[rgb]{0.51,0.51,0.51}{\it{#1}}}
+\newcommand{\hlppc}[1]{\textcolor[rgb]{0,0.51,0}{#1}}
+\newcommand{\hlopt}[1]{\textcolor[rgb]{0,0,0}{#1}}
+\newcommand{\hllin}[1]{\textcolor[rgb]{0.33,0.33,0.33}{#1}}
+\newcommand{\hlkwa}[1]{\textcolor[rgb]{0,0,0}{\bf{#1}}}
+\newcommand{\hlkwb}[1]{\textcolor[rgb]{0,0.34,0.68}{#1}}
+\newcommand{\hlkwc}[1]{\textcolor[rgb]{0,0,0}{\bf{#1}}}
+\newcommand{\hlkwd}[1]{\textcolor[rgb]{0,0,0.51}{#1}}
+\definecolor{bgcolor}{rgb}{0.88,0.92,0.93}
+\newsavebox{\hlboxopenbrace}
+\newsavebox{\hlboxclosebrace}
+\newsavebox{\hlboxlessthan}
+\newsavebox{\hlboxgreaterthan}
+\newsavebox{\hlboxdollar}
+\newsavebox{\hlboxunderscore}
+\newsavebox{\hlboxand}
+\newsavebox{\hlboxhash}
+\newsavebox{\hlboxat}
+\newsavebox{\hlboxbackslash}
+\newsavebox{\hlboxpercent}
+\newsavebox{\hlboxhat}
+\setbox\hlboxopenbrace=\hbox{\verb.{.}
+\setbox\hlboxclosebrace=\hbox{\verb.}.}
+\setbox\hlboxlessthan=\hbox{\verb.<.}
+\setbox\hlboxgreaterthan=\hbox{\verb.>.}
+\setbox\hlboxdollar=\hbox{\verb.$.}
+\setbox\hlboxunderscore=\hbox{\verb._.}
+\setbox\hlboxand=\hbox{\verb.&.}
+\setbox\hlboxhash=\hbox{\verb.#.}
+\setbox\hlboxat=\hbox{\verb. at .}
+\setbox\hlboxbackslash=\hbox{\verb.\.}
+\setbox\hlboxpercent=\hbox{\verb.\%.}
+\setbox\hlboxhat=\hbox{\verb.^.}
+\def\urltilda{\kern -.15em\lower .7ex\hbox{\~{}}\kern .04em}
+
+<<echo=FALSE,print=FALSE>>=
+prettyVersion <- packageDescription("RcppEigen")$Version
+prettyDate <- format(Sys.Date(), "%B %e, %Y")
+@
+
+\author{Douglas Bates}
+\title{An Introduction to \pkg{RcppEigen}}
+\date{\pkg{RcppEigen} version \Sexpr{prettyVersion} as of \Sexpr{prettyDate}}
+
+<<echo=FALSE>>=
+link <- function( f, package, text = f, root = "http://finzi.psych.upenn.edu/R/library/" ){
+ h <- if( missing(package) ) {
+ as.character( help( f ) )
+ } else {
+ as.character( help( f, package = paste( package, sep = "" ) ) )
+ }
+ if( ! length(h) ){
+ sprintf( "\\\\textbf{%s}", f )
+ } else {
+ rx <- "^.*/([^/]*?)/help/(.*?)$"
+ package <- sub( rx, "\\1", h, perl = TRUE )
+ page <- sub( rx, "\\2", h, perl = TRUE )
+ sprintf( "\\\\href{%s%s/html/%s.html}{\\\\texttt{%s}}", root, package, page, text )
+ }
+}
+linkS4class <- function( cl, package, text = cl, root = "http://finzi.psych.upenn.edu/R/library/" ){
+ link( sprintf("%s-class", cl), package, text, root )
+}
+# this will be integrated to package highlight later
+ex_highlight <- function( file, external.highlight = TRUE, verbatim = FALSE ){
+ if( verbatim ){
+ writeLines( "\\begin{verbatim}" )
+ writeLines( readLines( file ) )
+ writeLines( "\\end{verbatim}" )
+ } else {
+ tf <- tempfile()
+ if( external.highlight ){
+ cmd <- sprintf( 'highlight --input="%s" --output="%s" --out-format=latex --pretty-symbols', file, tf )
+ tryCatch( {
+ system( cmd )
+ tex <- readLines( tf )
+ keep <- seq( which( tex == "\\noindent" ), which( tex == "\\normalfont" ) )
+ tex <- c(
+ "\\vspace{1em}\\noindent\\fbox{\\begin{minipage}{0.9\\textwidth}" ,
+ tex[ keep ],
+ "\\end{minipage}}\\vspace{1em}" )
+ writeLines( tex )
+ })
+ } else {
+ r = renderer_latex( minipage = TRUE, doc = FALSE )
+ tex <- highlight( file, renderer = r , output = NULL )
+ writeLines( tex )
+ }
+ }
+ invisible(NULL)
+}
+
+require( inline )
+require( RcppEigen )
+@
+
+\begin{document}
+\maketitle
+
+\abstract{
+ \noindent
+ The \pkg{RcppEigen} package provides access to the \pkg{Eigen}
+ \proglang{C++} template library from \proglang{R}. \pkg{Rcpp}
+ classes and especially the packages \proglang{C++} templated
+ functions \code{as} and \code{wrap} provide the ``glue'' for passing
+ objects from \proglang{R} to \proglang{C++} and back.
+}
+
+\section{Introduction}
+\label{sec:intro}
+
+As stated in the \pkg{Rcpp} vignette, ``Extending \pkg{Rcpp}''
+\begin{quote}
+ \pkg{Rcpp} facilitates data interchange between \proglang{R} and
+ \proglang{C++} through the templated functions \texttt{Rcpp::as} (for
+ conversion of objects from \proglang{R} to \proglang{C++}) and
+ \texttt{Rcpp::wrap} (for conversion from \proglang{C++} to \proglang{R}).
+\end{quote}
+The \pkg{RcppEigen} package provides the header files composing the
+\pkg{Eigen} \proglang{C++} template library and implementations of
+\texttt{Rcpp::as} and \texttt{Rcpp::wrap} for the \proglang{C++}
+classes defined in \pkg{Eigen}.
+
+The \pkg{Eigen} classes themselves provide a high-performance,
+versatile and comprehensive representation of dense and sparse
+matrices and vectors, as well as decompositions and other functions
+to be applied to these objects. In the next section we introduce some
+of these classes and show how to interface to them from R.
+
+\section{Eigen classes}
+\label{sec:eclasses}
+
+Eigen provides templated classes for matrices, vectors and arrays. As
+in many \proglang{C++} template libraries using template
+meta-programming
+\citep{Abrahams+Gurtovoy:2004:TemplateMetaprogramming}, the templates
+themselves are very complicated. However, \pkg{Eigen} provides
+typedef's for the classes that correspond to \proglang{R} matrices and
+vectors, as shown in Table~\ref{tab:REigen}, and we will use these
+typedef's throughout this document.
+\begin{table}[tb]
+ \centering
+ \begin{tabular}{l l}
+ \hline
+ \multicolumn{1}{c}{\proglang{R} object type} & \multicolumn{1}{c}{\pkg{Eigen} class typedef}\\
+ \hline\\
+ numeric matrix & \code{MatrixXd}\\
+ integer matrix & \code{MatrixXi}\\
+ complex matrix & \code{MatrixXcd}\\
+ numeric vector & \code{VectorXd}\\
+ integer vector & \code{VectorXi}\\
+ complex vector & \code{VectorXcd}\\
+ \code{Matrix::dgCMatrix} & \code{SparseMatrix<double>}\\
+ \hline
+ \end{tabular}
+ \caption{Correspondence between R matrix and vector types and classes in the \code{Eigen} namespace.}
+ \label{tab:REigen}
+\end{table}
+
+The \proglang{C++} classes shown in Table~\ref{tab:REigen} are in the
+\code{Eigen} namespace, which means that they must be written as
+\code{Eigen::MatrixXd}. However, if we preface our use of these class
+names with a declaration like
+
+<<echo=FALSE>>=
+code <- 'using Eigen::MatrixXd;'
+writeLines( code, "code.cpp" )
+@
+<<echo=FALSE,results=tex>>=
+ex_highlight( "code.cpp" )
+@
+\\we can use these names without the qualifier. I prefer this approach.
+
+\subsection{Mapped matrices in Eigen}
+\label{sec:mapped}
+
+Storage for the contents of matrices from the classes shown in
+Table~\ref{tab:REigen} is allocated and controlled by the class
+constructors and destructors. Creating an instance of such a class
+from an \proglang{R} object involves copying its contents. An
+alternative is to have the contents of the \proglang{R} matrix or
+vector mapped to the contents of the object from the Eigen class. For
+dense matrices we use the Eigen templated class \code{Map}. For
+sparse matrices we use the Eigen templated class \code{MappedSparseMatrix}.
+
+We must, of course, be careful not to modify the contents of the
+\proglang{R} object in the \proglang{C++} code. It is a good idea to
+declare such objects as const.
+
+\subsection{Arrays in Eigen}
+\label{sec:arrays}
+
+For matrix and vector classes \pkg{Eigen} overloads the \texttt{'*'}
+operator to indicate matrix multiplication. Occasionally we want
+component-wise operations instead of matrix operations. The
+\code{Array} templated classes are used in \pkg{Eigen} for
+component-wise operations. Most often we use the \code{array} method
+for Matrix or Vector objects to create the array.
+
+\subsection{Structured matrices in \pkg{Eigen}}
+\label{sec:structured}
+
+There are \pkg{Eigen} classes for matrices with special structure such
+as symmetric matrices, triangular matrices and banded matrices. For
+dense matrices, these special structures are described as ``views'',
+meaning that the full dense matrix is stored but only part of the
+matrix is used in operations. For a symmetric matrix we need to
+specify whether the lower triangle or the upper triangle is to be used as
+the contents, with the other triangle defined by the implicit symmetry.
+
+
+\section{Some simple examples}
+\label{sec:simple}
+
+\proglang{C++} functions to perform simple operations on matrices or
+vectors can follow a pattern of:
+\begin{enumerate}
+\item Map the \proglang{R} objects passed as arguments into Eigen objects.
+\item Create the result.
+\item Return \code{Rcpp::wrap} applied to the result.
+\end{enumerate}
+
+An idiom for the first step is
+
+<<echo=FALSE>>=
+code <- 'using Eigen::Map;
+using Eigen::MatrixXd;
+using Rcpp::as;
+
+const Map<MatrixXd> A(as<Map<MatrixXd> >(AA));'
+writeLines( code, "code.cpp" )
+@
+<<echo=FALSE,results=tex>>=
+ex_highlight( "code.cpp" )
+@
+\\where \code{AA} is the name of the R object (called an \code{SEXP} in
+\proglang{C} and \proglang{C++}) passed to the \proglang{C++} function.
+
+The \code{cxxfunction} from the \pkg{inline} package for \proglang{R}
+and its \pkg{RcppEigen} plugin provide a convenient way of developing
+and debugging the \proglang{C++} code. For actual production code we
+generally incorporate the \proglang{C++} source code files in a
+package and include the line \code{LinkingTo: Rcpp, RcppEigen} in the
+package's \code{DESCRIPTION} file.
+
+
+The \code{cxxfunction} with the \code{"Rcpp"} or \code{"RcppEigen"}
+plugins has the \code{as} and \code{wrap} functions already defined as
+\code{Rcpp::as} and \code{Rcpp::wrap}. In the examples below we will
+omit these declarations. Do remember that you will need them in
+\proglang{C++} source code for a package.
+
+The first few examples are simply for illustration as the operations
+shown could be more effectively performed directly in \proglang{R}.
+We do compare the results from \pkg{Eigen} to those from the direct
+\proglang{R} results.
+
+\subsection{Transpose of an integer matrix}
+\label{sec:transpose}
+
+We create a simple matrix of integers
+<<Adef>>=
+(A <- matrix(1:6, ncol=2))
+str(A)
+@
+and use the \code{transpose} method for the \pkg{Eigen::MatrixXi}
+class to return its transpose.
+
+<<echo=FALSE>>=
+code <- 'using Eigen::Map;
+using Eigen::MatrixXi;
+ // Map the integer matrix AA from R
+const Map<MatrixXi> A(as<Map<MatrixXi> >(AA));
+ // evaluate and return the transpose of A
+const MatrixXi At(A.transpose());
+return wrap(At);'
+writeLines( code, "code.cpp" )
+@
+<<echo=FALSE,results=tex>>=
+ex_highlight( "code.cpp" )
+@
+<<>>=
+ftrans <- cxxfunction(signature(AA = "matrix"),
+ paste(readLines( "code.cpp" ), collapse = "\n"),
+ plugin = "RcppEigen")
+(At <- ftrans(A))
+stopifnot(all.equal(At, t(A)))
+@
+
+For numeric or integer matrices the \code{adjoint} method is
+equivalent to the \code{transpose} method. For complex matrices, the
+adjoint is the conjugate of the transpose. In keeping with the
+conventions in the \pkg{Eigen} documentation we prefer the name
+\code{adjoint} with numeric or integer matrices.
+
+\subsection{Products and cross-products}
+\label{sec:products}
+
+As mentioned in Sec.~\ref{sec:arrays}, the \code{'*'} operator
+performs matrix multiplication on Matrix or Vector objects.
+<<echo=FALSE>>=
+code <- 'using Eigen::Map;
+using Eigen::MatrixXi;
+const Map<MatrixXi> B(as<Map<MatrixXi> >(BB));
+const Map<MatrixXi> C(as<Map<MatrixXi> >(CC));
+return List::create(_["A %*% B"] = B * C,
+ _["crossprod(A, B)"] = B.adjoint() * C);'
+writeLines( code, "code.cpp" )
+@
+<<echo=FALSE,results=tex>>=
+ex_highlight( "code.cpp" )
+@
+
+<<>>=
+fprod <- cxxfunction(signature(BB = "matrix", CC = "matrix"),
+ paste(readLines( "code.cpp" ), collapse = "\n"), "RcppEigen")
+B <- matrix(1:4, ncol=2); C <- matrix(6:1, nrow=2)
+str(fp <- fprod(B, C))
+stopifnot(all.equal(fp[[1]], B %*% C), all.equal(fp[[2]], crossprod(B, C)))
+@
+
+Notice that the \code{create} method for the \pkg{Rcpp} class
+\code{List} implicitly applies \code{Rcpp::wrap} to its arguments.
+
+\subsection{Crossproduct of a single matrix}
+\label{sec:crossproduct}
+
+As shown in the last example, the \proglang{R} function
+\code{crossprod} calculates the product of the transpose of its first
+argument with its second argument. The single argument form,
+\code{crossprod(X)}, evaluates $\bm X^\prime\bm X$. We could, of course, calculate this product as
+<<eval=FALSE>>=
+t(X) %*% X
+@
+but \code{crossprod(X)} takes roughly half as long because
+the result is known to be symmetric. The function \code{tcrossprod}
+evaluates \code{crossprod(t(X))} without actually forming the transpose.
+
+To express these calculations in Eigen we create a \code{SelfAdjointView},
+which is a dense matrix of which only one triangle is used, the other
+triangle being inferred from the symmetry. (``self-adjoint'' is
+equivalent to symmetric when applied to non-complex matrices.)
+
+<<echo=FALSE>>=
+code <- 'using Eigen::Map;
+using Eigen::MatrixXi;
+using Eigen::Lower;
+
+const Map<MatrixXi> A(as<Map<MatrixXi> >(AA));
+const int m(A.rows()), n(A.cols());
+MatrixXi AtA(MatrixXi(n, n).setZero().selfadjointView<Lower>().rankUpdate(A.adjoint()));
+MatrixXi AAt(MatrixXi(m, m).setZero().selfadjointView<Lower>().rankUpdate(A));
+
+return List::create(_["crossprod(A)"] = AtA,
+ _["tcrossprod(A)"] = AAt); '
+writeLines( code, "code.cpp" )
+@
+<<echo=FALSE,results=tex>>=
+ex_highlight( "code.cpp" )
+@
+<<>>=
+fcprd <- cxxfunction(signature(AA = "matrix"),
+ paste(readLines( "code.cpp" ), collapse = "\n"), "RcppEigen")
+str(crp <- fcprd(A))
+stopifnot(all.equal(crp[[1]], crossprod(A)), all.equal(crp[[2]], tcrossprod(A)))
+@
+
+To some, the expressions to construct \code{AtA} and \code{AAt} in
+that code fragment are compact and elegant. To others they are
+hopelessly confusing. If you find yourself in the latter group, you
+just need to read the expression left to right. So, for example, we
+construct \code{AAt} by creating a general integer matrix of size
+$m\times m$ (where $\bm A$ is $m\times n$), ensure that all its
+elements are zero, regard it as a self-adjoint (i.e. symmetric) matrix
+using the elements in the lower triangle, then add $\bm A\bm A^\prime$
+to it and convert back to a general matrix form (i.e.the strict
+lower triangle is copied into the strict upper triangle).
+
+For these products we could use either the lower triangle or the upper
+triangle because the result is going to be symmetrized before being returned.
+
+\subsection{Cholesky decomposition of the crossprod}
+\label{sec:chol}
+
+The Cholesky decomposition of the positive-definite, symmetric matrix,
+$\bm A$, can be written in several forms. Numerical analysts define
+the ``LLt'' form as the lower triangular matrix, $\bm L$, such that
+$\bm A=\bm L\bm L^\prime$ and the ``LDLt'' form as a unit lower
+triangular matrix $\bm L$ and a diagonal matrix $\bm D$ with positive
+diagonal elements such that $\bm A=\bm L\bm D\bm L^\prime$.
+Statisticians often write the decomposition as $\bm A=\bm R^\prime\bm
+R$ where $\bm R$ is an upper triangular matrix. Of course, this $\bm
+R$ is simply the transpose of $\bm L$ from the ``LLt'' form.
+
+The templated \pkg{Eigen} classes for the LLt and LDLt forms are
+called \code{LLT} and \code{LDLT}. In general we would preserve the
+objects from these classes so that we could use them for solutions of
+linear systems. For illustration we simply return the matrix $\bm L$
+from the ``LLt'' form.
+
+Because the Cholesky decomposition involves taking square roots we
+switch to numeric matrices.
+<<storage>>=
+storage.mode(A) <- "double"
+@
+<<echo=FALSE>>=
+code <- 'using Eigen::Map;
+using Eigen::MatrixXd;
+using Eigen::LLT;
+using Eigen::Lower;
+
+const Map<MatrixXd> A(as<Map<MatrixXd> >(AA));
+const int n(A.cols());
+const LLT<MatrixXd> llt(MatrixXd(n, n).setZero().
+ selfadjointView<Lower>().
+ rankUpdate(A.adjoint()));
+
+return List::create(_["L"] = MatrixXd(llt.matrixL()),
+ _["R"] = MatrixXd(llt.matrixU()));'
+writeLines( code, "code.cpp" )
+@
+<<echo=FALSE,results=tex>>=
+ex_highlight( "code.cpp" )
+@
+<<>>=
+fchol <- cxxfunction(signature(AA = "matrix"),
+ paste(readLines( "code.cpp" ), collapse = "\n"), "RcppEigen")
+(ll <- fchol(A))
+stopifnot(all.equal(ll[[2]], chol(crossprod(A))))
+@
+
+\subsection{Determinant of the cross-product matrix}
+\label{sec:determinant}
+
+The ``D-optimal'' criterion for experimental design chooses the design
+that maximizes the determinant, $|\bm X^\prime\bm X|$, for the
+$n\times p$ model matrix (or Jacobian matrix), $\bm X$. The
+determinant, $|\bm L|$, of the the $p\times p$ lower Cholesky factor
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/rcpp -r 3210
More information about the Rcpp-commits
mailing list