[Rcpp-commits] r3403 - pkg/RcppEigen/vignettes
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Dec 2 20:09:32 CET 2011
Author: dmbates
Date: 2011-12-02 20:09:31 +0100 (Fri, 02 Dec 2011)
New Revision: 3403
Modified:
pkg/RcppEigen/vignettes/Rcpp.bib
pkg/RcppEigen/vignettes/RcppEigen-intro-nojss.Rnw
Log:
JSS corrections.
Modified: pkg/RcppEigen/vignettes/Rcpp.bib
===================================================================
--- pkg/RcppEigen/vignettes/Rcpp.bib 2011-12-01 11:08:34 UTC (rev 3402)
+++ pkg/RcppEigen/vignettes/Rcpp.bib 2011-12-02 19:09:31 UTC (rev 3403)
@@ -7,7 +7,7 @@
@Misc{cpp11,
author = "ISO/IEC",
organization = "{International Organization for Standardization}",
- title = "C++ 2011 Standard Document 14882:2011",
+ title = "\proglang{C++} 2011 Standard Document 14882:2011",
howpublished = {ISO/IEC Standard Group for Information Technology / Programming Languages / C++},
year = 2011,
url = "http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=50372",
@@ -24,7 +24,7 @@
@Book{Abrahams+Gurtovoy:2004:TemplateMetaprogramming,
author = {David Abrahams and Aleksey Gurtovoy},
- title = {{C++} {T}emplate {M}etaprogramming: Concepts, Tools
+ title = {\proglang{C++} {T}emplate {M}etaprogramming: Concepts, Tools
and Techniques from {B}oost and Beyond},
publisher = {Addison-Wesley},
year = 2004,
@@ -32,7 +32,7 @@
}
@Manual{Armstrong:2009:RAbstraction,
- title = {{RAbstraction}: {C++} abstraction for {R} objects},
+ title = {\pkg{RAbstraction}: \proglang{C++} abstraction for \proglang{R} objects},
author = {Whit Armstrong},
year = 2009,
note = {Code repository last updated 2009-07-22.},
@@ -40,7 +40,7 @@
}
@Manual{Armstrong:2009:RObjects,
- title = {{RObjects}: {C++} wrapper for R objects (a better
+ title = {\pkg{RObjects}: \proglang{C++} wrapper for \proglang{R} objects (a better
implementation of {RAbstraction}},
author = {Whit Armstrong},
year = 2009,
@@ -50,7 +50,7 @@
@InProceedings{Bates+DebRoy:2001:C++Classes,
author = {Douglas M. Bates and Saikat DebRoy},
- title = {{C++} Classes for {R} Objects},
+ title = {\proglang{C++} Classes for \proglang{R} Objects},
booktitle = {Proceedings of the 2nd International Workshop on Distributed
Statistical Computing, March 15--17, 2001, Technische
Universit\"at Wien, Vienna, Austria},
@@ -63,7 +63,7 @@
@Misc{Brokken:2011:Cpp,
author = {Frank B. Brokken},
- title = {C++ Annotations},
+ title = {\proglang{C++} Annotations},
howpublished = {Electronic book, University of Groningen},
year = 2011,
url = {http://www.icce.rug.nl/documents/cplusplus/}
@@ -71,7 +71,7 @@
@Book{Chambers:2008:SoDA,
author = {John M. Chambers},
- title = {Software for Data Analysis: Programming with {R}},
+ title = {Software for Data Analysis: Programming with \proglang{R}},
publisher = {Springer-Verlag},
year = 2008,
series = {Statistics and Computing},
@@ -80,7 +80,7 @@
}
@Manual{CRAN:RInside,
- title = {RInside: C++ classes to embed R in C++ applications},
+ title = {\pkg{RInside}: \proglang{C++} classes to embed \proglang{R} in \proglang{C++} applications},
author = {Dirk Eddelbuettel and Romain Fran\c{c}ois},
year = 2010,
note = {R package version 0.2.3},
@@ -88,7 +88,7 @@
}
@Manual{CRAN:RProtoBuf,
- title = {RProtoBuf: R Interface to the Protocol Buffers API},
+ title = {\pkg{RProtoBuf}: \proglang{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},
@@ -96,7 +96,7 @@
}
@Manual{CRAN:RQuantLib,
- title = {RQuantLib: {R} interface to the {QuantLib} library},
+ title = {\pkg{RQuantLib}: \proglang{R} interface to the {QuantLib} library},
author = {Dirk Eddelbuettel and Khanh Nguyen},
year = 2011,
note = {R package version 0.3.6},
@@ -104,7 +104,7 @@
}
@Article{JSS:Rcpp,
- title = {{Rcpp}: Seamless {R} and {C++} Integration},
+ title = {\pkg{Rcpp}: Seamless \proglang{R} and \proglang{C++} Integration},
author = {Dirk Eddelbuettel and Romain Fran\c{c}ois},
journal = {Journal of Statistical Software},
year = 2011,
@@ -115,7 +115,7 @@
}
@Manual{CRAN:Rcpp,
- title = {{Rcpp}: Seamless {R} and {C++} Integration},
+ title = {\pkg{Rcpp}: Seamless \proglang{R} and \proglang{C++} Integration},
author = {Dirk Eddelbuettel and Romain Fran\c{c}ois},
year = 2011,
note = {R package version 0.9.4},
@@ -123,7 +123,7 @@
}
@Manual{CRAN:RcppArmadillo,
- title = {RcppArmadillo: Rcpp integration for Armadillo
+ title = {\pkg{RcppArmadillo}: \pkg{Rcpp} integration for Armadillo
templated linear algebra library},
author = {Romain Fran\c{c}ois and Dirk Eddelbuettel and
Douglas Bates},
@@ -133,7 +133,7 @@
}
@Manual{CRAN:RcppClassic,
- title = {RcppClassic: Deprecated 'classic' Rcpp API},
+ title = {\pkg{RcppClassic}: Deprecated 'classic' \pkg{Rcpp} API},
author = {Dirk Eddelbuettel and Romain Fran\c{c}ois},
year = 2011,
note = {R package version 0.9.1},
@@ -141,7 +141,7 @@
}
@Manual{CRAN:RcppDE,
- title = {RcppDE: Global optimization by differential evolution in C++},
+ title = {\pkg{RcppDE}: Global optimization by differential evolution in \proglang{C++}},
author = {Dirk Eddelbuettel},
year = 2010,
note = {R package version 0.1.0},
@@ -149,8 +149,8 @@
}
@Manual{CRAN:RcppExamples,
- title = {RcppExamples: Examples using {Rcpp} to interface {R}
- and {C++}},
+ title = {\pkg{RcppExamples}: Examples using \pkg{Rcpp} to interface \proglang{R}
+ and \proglang{C++}},
author = {Dirk Eddelbuettel and Romain Fran\c{c}ois},
year = 2010,
note = {R package version 0.1.2},
@@ -158,7 +158,7 @@
}
@Manual{CRAN:RcppGSL,
- title = {RcppGSL: Rcpp integration for GNU GSL vectors and matrices},
+ title = {\pkg{RcppGSL}: \pkg{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},
@@ -166,7 +166,7 @@
}
@Manual{CRAN:Rserve,
- title = {Rserve: Binary R server},
+ title = {\pkg{Rserve}: Binary R server},
author = {Simon Urbanek},
year = 2011,
note = {R package version 0.6-3},
@@ -174,7 +174,7 @@
}
@Manual{CRAN:cxxPack,
- title = {cxxpack: {R/C++} Tools for Literate Statistical
+ title = {\pkg{cxxpack}: \proglang{R}/\proglang{C++} Tools for Literate Statistical
Practice},
author = {Dominick Samperi},
year = 2010,
@@ -183,7 +183,7 @@
}
@Manual{CRAN:highlight,
- title = {highlight: Syntax highlighter},
+ title = {\pkg{highlight}: Syntax highlighter},
author = {Romain Fran\c{c}ois},
year = 2010,
note = {R package version 0.2-5},
@@ -191,8 +191,8 @@
}
@Manual{CRAN:inline,
- title = {inline: Inline C, C++, Fortran function calls from
- R},
+ title = {\pkg{inline}: Inline \proglang{C}, \proglang{C++},
+ \proglang{Fortran} function calls from \proglang{R}},
author = {Oleg Sklyar and Duncan Murdoch and Mike Smith and
Dirk Eddelbuettel and Romain Fran\c{c}ois},
year = 2010,
@@ -201,7 +201,7 @@
}
@Manual{CRAN:Matrix,
- title = {Matrix: Sparse and Dense Matrix Classes and Methods},
+ title = {\pkg{Matrix}: Sparse and Dense Matrix Classes and Methods},
author = {Douglas Bates and Martin Maechler},
year = 2011,
note = {R package version 1.0-2},
@@ -209,7 +209,7 @@
}
@Manual{CRAN:minqa,
- title = {minqa: Derivative-free optimization algorithms by
+ title = {\pkg{minqa}: Derivative-free optimization algorithms by
quadratic approximation},
author = {Douglas Bates and Katharine M. Mullen and John
C. Nash and Ravi Varadhan},
@@ -219,7 +219,7 @@
}
@Manual{CRAN:rbenchmark,
- title = {rbenchmark: Benchmarking routine for R},
+ title = {\pkg{rbenchmark}: Benchmarking routine for \proglang{R}},
author = {Wacek Kusnierczyk},
year = 2010,
note = {R package version 0.3},
@@ -268,8 +268,8 @@
@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},
+ title = {{R/Cpp}: Interface Classes to Simplify Using \proglang{R}
+ Objects in \proglang{C++} Extensions},
note = {Unpublished manuscript, University at Buffalo},
url =
{http://sphhp.buffalo.edu/biostat/research/techreports/UB_Biostatistics_TR0702.pdf},
@@ -290,7 +290,7 @@
}
@Manual{Liang:2008:rcppbind,
- title = {rcppbind: {A} template library for R/C++ developers},
+ title = {\pkg{rcppbind}: {A} template library for \proglang{R}/\proglang{C++} developers},
author = {Gang Liang},
year = 2008,
note = {R package version 1.0},
@@ -299,7 +299,7 @@
@Book{Lippman+Lajoie+Moo:2005:Cpp_Primer,
author = {Stanley B. Lippman and Jos\'{e}e Lajoie and Barbara E. Moo},
- title = {The C++ Primer},
+ title = {The \proglang{C++} Primer},
publisher = {Addison-Wesley},
address = {Boston},
year = 2005,
@@ -308,7 +308,7 @@
@book{Meyers:1995:MoreEffectiveC++,
author = {Scott Meyers},
- title = {More Effective C++: 35 New Ways to Improve Your
+ title = {More Effective \proglang{C++}: 35 New Ways to Improve Your
Programs and Designs},
year = 1995,
note = {{ISBN} 020163371X},
@@ -328,7 +328,7 @@
@book{Meyers:2005:EffectiveC++,
author = {Scott Meyers},
- title = {Effective C++: 55 Specific Ways to Improve Your
+ title = {Effective \proglang{C++}: 55 Specific Ways to Improve Your
Programs and Designs},
year = 2005,
note = {{ISBN} 978-0321334879},
@@ -340,7 +340,7 @@
@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},
+ title = {The \proglang{C++} Standard Template Library},
publisher = {Prentice Hall PTR},
year = 2000,
note = {{ISBN} 978-0134376332},
@@ -351,7 +351,7 @@
organization = RFoundation,
address = {Vienna, Austria},
year = 2010,
- title = "R Installation and Administration",
+ title = "\proglang{R} Installation and Administration",
note = {{ISBN} 3-900051-09-7},
url = manuals # "R-admin.html"
}
@@ -361,7 +361,7 @@
organization = RFoundation,
address = {Vienna, Austria},
year = 2011,
- title = "Writing R extensions",
+ title = "Writing \proglang{R} Extensions",
note = {{ISBN} 3-900051-11-9},
url = manuals # "R-exts.html"
}
@@ -371,13 +371,13 @@
organization = RFoundation,
address = {Vienna, Austria},
year = 2011,
- title = "R internals",
+ title = "\proglang{R} Internals",
note = {{ISBN} 3-900051-14-3},
url = manuals # "R-ints.html"
}
@manual{R:Main,
- title = {R: A Language and Environment for Statistical
+ title = {\proglang{R}: A Language and Environment for Statistical
Computing},
author = RCoreTeam,
organization = RFoundation,
@@ -392,7 +392,7 @@
organization = RFoundation,
address = {Vienna, Austria},
year = 2011,
- title = "R language",
+ title = "\proglang{R} language",
note = {{ISBN} 3-900051-13-5},
url = manuals # "R-lang.html"
}
@@ -406,7 +406,7 @@
}
@Manual{Samperi:2009:RcppTemplate,
- title = {RcppTemplate: Rcpp {R/C++} Object Mapping Library
+ title = {\pkg{RcppTemplate}: Rcpp \proglang{R}/\proglang{C++} Object Mapping Library
and Package Template},
author = {Dominick Samperi},
year = 2009,
@@ -416,7 +416,7 @@
@TechReport{Sanderson:2010:Armadillo,
author = {Conrad Sanderson},
- title = {{Armadillo}: {An} open source {C++} Algebra Library
+ title = {{Armadillo}: {An} open source \proglang{C++} Algebra Library
for Fast Prototyping and Computationally Intensive
Experiments },
institution = {{NICTA}},
@@ -426,7 +426,7 @@
@Book{Stroustrup:1997:Cpp,
author = {Bjarne Stroustrup},
- title = {The C++ Programming Language},
+ title = {The \proglang{C++} Programming Language},
publisher = {Addison-Wesley},
address = {Boston},
year = 1997,
@@ -436,7 +436,7 @@
@Article{TempleLang:2009:ModestProposal,
author = {Duncan {Temple Lang}},
title = {A modest proposal: an approach to making the
- internal {R} system extensible},
+ internal \proglang{R} system extensible},
journal = {Computational Statistics},
year = 2009,
volume = 24,
@@ -447,7 +447,7 @@
@Article{TempleLang:2009:RGCCTranslationUnit,
author = {Duncan {Temple Lang}},
- title = {Working with meta-data from {C/C++} code in {R}: the
+ title = {Working with meta-data from \proglang{C}/\proglang{C++} code in \proglang{R}: the
{RGCCTranslationUnit} package},
journal = {Computational Statistics},
year = 2009,
@@ -459,7 +459,7 @@
@InProceedings{Urbanek:2003:Rserve,
author = {Simon Urbanek},
- title = {{Rserve}: A Fast Way to Provide {R} Functionality to
+ title = {\pkg{Rserve}: A Fast Way to Provide \proglang{R} Functionality to
Applications},
booktitle = {Proceedings of the 3rd International Workshop on Distributed
Statistical Computing, Vienna, Austria},
@@ -471,7 +471,7 @@
@Book{Vandevoorde+Josuttis:2003:Templates,
author = {David Vandevoorde and Nicolai M. Josuttis},
- title = {{C++} {T}emplates: The Complete Guide},
+ title = {\proglang{C++} {T}emplates: The Complete Guide},
publisher = {Addison-Wesley},
year = 2003,
address = {Boston}
Modified: pkg/RcppEigen/vignettes/RcppEigen-intro-nojss.Rnw
===================================================================
--- pkg/RcppEigen/vignettes/RcppEigen-intro-nojss.Rnw 2011-12-01 11:08:34 UTC (rev 3402)
+++ pkg/RcppEigen/vignettes/RcppEigen-intro-nojss.Rnw 2011-12-02 19:09:31 UTC (rev 3403)
@@ -1,5 +1,5 @@
-
\documentclass[shortnames,article,nojss]{jss}
+%]{jss}
%\VignetteIndexEntry{RcppEigen-intro}
%\VignetteKeywords{linear algebra, template programming, C++, R, Rcpp}
%\VignettePackage{RcppEigen}
@@ -151,13 +151,13 @@
As stated in the \pkg{Rcpp} \citep{CRAN: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
+ \proglang{C++} through the templated functions \code{Rcpp::as} (for
conversion of objects from \proglang{R} to \proglang{C++}) and
- \texttt{Rcpp::wrap} (for conversion from \proglang{C++} to \proglang{R}).
+ \code{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, along with implementations of
-\texttt{Rcpp::as} and \texttt{Rcpp::wrap} for the \proglang{C++}
+\code{Rcpp::as} and \code{Rcpp::wrap} for the \proglang{C++}
classes defined in \pkg{Eigen}.
The \pkg{Eigen} classes themselves provide high-performance,
@@ -198,7 +198,7 @@
\code{Matrix::dgCMatrix} \phantom{XXX} & \code{SparseMatrix<double>}\\
\bottomrule
\end{tabular}
- \caption{Correspondence between R matrix and vector types and classes in the \pkg{Eigen} namespace.}
+ \caption{Correspondence between \proglang{R} matrix and vector types and classes in the \pkg{Eigen} namespace.}
\label{tab:REigen}
\end{table}
@@ -341,12 +341,12 @@
The next \proglang{R} code snippet creates a simple matrix of integers
\begin{verbatim}
-> (A <- matrix(1:6, ncol=2))
+R> (A <- matrix(1:6, ncol=2))
[,1] [,2]
[1,] 1 4
[2,] 2 5
[3,] 3 6
-> str(A)
+R> str(A)
int [1:3, 1:2] 1 2 3 4 5 6
\end{verbatim}
and, in Figure~\ref{trans}, the \code{transpose()} method for the
@@ -383,12 +383,12 @@
is used on the matrix $\bm A$ shown above, and one can check that it works as intended
by comparing the output to an explicit transpose of the matrix argument.
\begin{verbatim}
-> ftrans <- cxxfunction(signature(AA="matrix"), transCpp, plugin="RcppEigen")
-> (At <- ftrans(A))
+R> ftrans <- cxxfunction(signature(AA="matrix"), transCpp, plugin="RcppEigen")
+R> (At <- ftrans(A))
[,1] [,2] [,3]
[1,] 1 2 3
[2,] 4 5 6
-> stopifnot(all.equal(At, t(A)))
+R> stopifnot(all.equal(At, t(A)))
\end{verbatim}
For numeric or integer matrices the \code{adjoint()} method is
@@ -402,9 +402,9 @@
\subsection{Products and cross-products}
\label{sec:products}
-As mentioned in Sec.~\ref{sec:arrays}, the \code{`*'} operator
-performs matrix multiplication on \code{Eigen::Matrix} or
-\code{Eigen::Vector} objects. The \proglang{C++} code in
+As mentioned in Section~\ref{sec:arrays}, the \code{`*'} operator is
+overloaded as matrix multiplication for the various matrix and vector
+classes in \pkg{Eigen}. The \proglang{C++} code in
Figure~\ref{prod} produces a list containing both the product and
cross-product of its two arguments.
@@ -426,15 +426,15 @@
\end{figure}
\begin{verbatim}
-> fprod <- cxxfunction(signature(BB = "matrix", CC = "matrix"),
-+ prodCpp, "RcppEigen")
-> B <- matrix(1:4, ncol=2)
-> C <- matrix(6:1, nrow=2)
-> str(fp <- fprod(B, C))
+R> fprod <- cxxfunction(signature(BB = "matrix", CC = "matrix"),
++ prodCpp, "RcppEigen")
+R> B <- matrix(1:4, ncol=2)
+R> C <- matrix(6:1, nrow=2)
+R> str(fp <- fprod(B, C))
List of 2
$ B %*% C : int [1:2, 1:3] 21 32 13 20 5 8
$ crossprod(B, C): int [1:2, 1:3] 16 38 10 24 4 10
-> stopifnot(all.equal(fp[[1]], B %*% C), all.equal(fp[[2]], crossprod(B, C)))
+R> stopifnot(all.equal(fp[[1]], B %*% C), all.equal(fp[[2]], crossprod(B, C)))
\end{verbatim}
Note that the \code{create} class method for \code{Rcpp::List}
implicitly applies \code{Rcpp::wrap} to its arguments.
@@ -499,13 +499,13 @@
\label{crossprod}
\end{figure}
\begin{verbatim}
-> fcprd <- cxxfunction(signature(AA = "matrix"), crossprodCpp, "RcppEigen")
-> str(crp <- fcprd(A))
+R> fcprd <- cxxfunction(signature(AA = "matrix"), crossprodCpp, "RcppEigen")
+R> str(crp <- fcprd(A))
List of 2
$ crossprod(A) : int [1:2, 1:2] 14 32 32 77
$ tcrossprod(A): int [1:3, 1:3] 17 22 27 22 29 36 27 36 45
-> stopifnot(all.equal(crp[[1]], crossprod(A)),
-+ all.equal(crp[[2]], tcrossprod(A)))
+R> stopifnot(all.equal(crp[[1]], crossprod(A)),
++ all.equal(crp[[2]], tcrossprod(A)))
\end{verbatim}
To some, the expressions in Figure~\ref{crossprod} to construct
@@ -514,9 +514,9 @@
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$), ensuring that all its
-elements are zero, regarding it as a self-adjoint (\textit{i.e.} symmetric) matrix
+elements are zero, regarding it as a self-adjoint (\textit{i.e.,} symmetric) matrix
using the elements in the lower triangle, then adding $\bm A\bm A^\prime$
-to it and converting back to a general matrix form (\textit{i.e.} the strict lower
+to it and converting back to a general matrix form (\textit{i.e.,} the strict lower
triangle is copied into the strict upper triangle).
For these products one could define the symmetric matrix from either
@@ -590,9 +590,9 @@
\end{figure}
\begin{verbatim}
-> storage.mode(A) <- "double"
-> fchol <- cxxfunction(signature(AA = "matrix"), cholCpp, "RcppEigen", incl)
-> (ll <- fchol(A))
+R> storage.mode(A) <- "double"
+R> fchol <- cxxfunction(signature(AA = "matrix"), cholCpp, "RcppEigen", incl)
+R> (ll <- fchol(A))
$L
[,1] [,2]
[1,] 3.74166 0.00000
@@ -603,7 +603,7 @@
[1,] 3.74166 8.55236
[2,] 0.00000 1.96396
-> stopifnot(all.equal(ll[[2]], chol(crossprod(A))))
+R> stopifnot(all.equal(ll[[2]], chol(crossprod(A))))
\end{verbatim}
@@ -651,8 +651,8 @@
\end{figure}
\begin{verbatim}
-> fdet <- cxxfunction(signature(AA = "matrix"), cholDetCpp, "RcppEigen", incl)
-> unlist(ll <- fdet(A))
+R> fdet <- cxxfunction(signature(AA = "matrix"), cholDetCpp, "RcppEigen", incl)
+R> unlist(ll <- fdet(A))
d1 d2 ld
54.00000 54.00000 3.98898
\end{verbatim}
@@ -727,10 +727,10 @@
(\code{lm.fit} is the workhorse function called by \code{lm} once the
model matrix and response have been evaluated).
\begin{verbatim}
-> lltLS <- cxxfunction(signature(XX = "matrix", yy = "numeric"),
-+ lltLSCpp, "RcppEigen", incl)
-> data(trees, package="datasets")
-> str(lltFit <- with(trees, lltLS(cbind(1, log(Girth)), log(Volume))))
+R> lltLS <- cxxfunction(signature(XX = "matrix", yy = "numeric"),
++ lltLSCpp, "RcppEigen", incl)
+R> data(trees, package="datasets")
+R> str(lltFit <- with(trees, lltLS(cbind(1, log(Girth)), log(Volume))))
List of 7
$ coefficients : num [1:2] -2.35 2.2
$ fitted.values: num [1:31] 2.3 2.38 2.43 2.82 2.86 ...
@@ -739,7 +739,7 @@
$ df.residual : int 29
$ rank : int 2
$ Std. Error : num [1:2] 0.2307 0.0898
-> str(lmFit <- with(trees, lm.fit(cbind(1, log(Girth)), log(Volume))))
+R> str(lmFit <- with(trees, lm.fit(cbind(1, log(Girth)), log(Volume))))
List of 8
$ coefficients : Named num [1:2] -2.35 2.2
..- attr(*, "names")= chr [1:2] "x1" "x2"
@@ -757,10 +757,10 @@
..$ rank : int 2
..- attr(*, "class")= chr "qr"
$ df.residual : int 29
-> for (nm in c("coefficients", "residuals", "fitted.values", "rank"))
-+ stopifnot(all.equal(lltFit[[nm]], unname(lmFit[[nm]])))
-> stopifnot(all.equal(lltFit[["Std. Error"]],
-+ unname(coef(summary(lm(log(Volume) ~ log(Girth), trees)))[,2])))
+R> for (nm in c("coefficients", "residuals", "fitted.values", "rank"))
++ stopifnot(all.equal(lltFit[[nm]], unname(lmFit[[nm]])))
+R> stopifnot(all.equal(lltFit[["Std. Error"]],
++ unname(coef(summary(lm(log(Volume) ~ log(Girth), trees)))[,2])))
\end{verbatim}
@@ -872,26 +872,26 @@
the model.
\begin{verbatim}
-> dd <- data.frame(f1 = gl(4, 6, labels = LETTERS[1:4]),
-+ f2 = gl(3, 2, labels = letters[1:3]))[-(7:8), ]
-> xtabs(~ f2 + f1, dd) # one missing cell
+R> dd <- data.frame(f1 = gl(4, 6, labels = LETTERS[1:4]),
++ f2 = gl(3, 2, labels = letters[1:3]))[-(7:8), ]
+R> xtabs(~ f2 + f1, dd) # one missing cell
f1
f2 A B C D
a 2 0 2 2
b 2 2 2 2
c 2 2 2 2
-> mm <- model.matrix(~ f1 * f2, dd)
-> kappa(mm) # large condition number, indicating rank deficiency
+R> mm <- model.matrix(~ f1 * f2, dd)
+R> kappa(mm) # large condition number, indicating rank deficiency
[1] 4.30923e+16
-> rcond(mm) # alternative evaluation, the reciprocal condition number
+R> rcond(mm) # alternative evaluation, the reciprocal condition number
[1] 2.3206e-17
-> (c(rank=qr(mm)$rank, p=ncol(mm))) # rank as computed in R's qr function
+R> (c(rank=qr(mm)$rank, p=ncol(mm))) # rank as computed in R's qr function
rank p
11 12
-> set.seed(1)
-> dd$y <- mm %*% seq_len(ncol(mm)) + rnorm(nrow(mm), sd = 0.1)
-> fm1 <- lm(y ~ f1 * f2, dd)
-> writeLines(capture.output(print(summary(fm1), signif.stars=FALSE))[9:22])
+R> set.seed(1)
+R> dd$y <- mm %*% seq_len(ncol(mm)) + rnorm(nrow(mm), sd = 0.1)
+R> fm1 <- lm(y ~ f1 * f2, dd)
+R> writeLines(capture.output(print(summary(fm1), signif.stars=FALSE))[9:22])
Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.9779 0.0582 16.8 3.4e-09
@@ -911,7 +911,7 @@
The \code{lm} function for fitting linear models in \proglang{R} uses
a rank-revealing form of the QR decomposition. When the model matrix
is determined to be rank deficient, according to the threshold used in
-\proglang{R}'s QR decomposition, the model matrix is reduced to
+\proglang{R}'s \code{qr} function, the model matrix is reduced to
$\rank{(\bm X)}$ columns by pivoting selected columns (those that are
apparently linearly dependent on columns to their left) to the right
hand side of the matrix. A solution for this reduced model matrix is
@@ -934,7 +934,7 @@
elements of $\bm D_1$ and whose last $p-r$ diagonal elements are zero.
The tolerance for determining if an element of the diagonal of $\bm D_1$
is considered to be (effectively) zero is a multiple of the largest
-singular value (\textit{i.e.} the $(1,1)$ element of $\bm D$).
+singular value (\textit{i.e.,} the $(1,1)$ element of $\bm D$).
The pseudo-inverse, $\bm X^+$, of $\bm X$ is defined as
\begin{displaymath}
\bm X^+=\bm V\bm D_1^+\bm U_1^\prime .
@@ -970,7 +970,7 @@
\code{.maxCoeff()}) and the use of a \code{threshold()} function
provides greater generality for the function. It can be used on the
eigenvalues of $\bm X^\prime\bm X$, as shown in
-Sec.~\ref{sec:eigendecomp}, even though these are returned in
+Section~\ref{sec:eigendecomp}, even though these are returned in
increasing order, as opposed to the decreasing order of the singular
values.
@@ -1013,7 +1013,8 @@
in $\bm X$, in which case the estimated coefficients are just one of
an infinite number of coefficient vectors that produce the same fitted
values. It happens that the solution from this pseudo-inverse is the
-minimum norm solution.
+minimum norm solution (in the sense that $\|\bm\beta\|^2$ is minimized
+among those $\bm\beta$ that minimize $\|\bm y-\bm X\bm\beta\|^2$).
The standard errors of the coefficient estimates in the rank-deficient
case must be interpreted carefully. The solution with one or more missing
@@ -1180,7 +1181,7 @@
Just to check that the code in Figure~\ref{ColPivQRLS} does indeed provide the desired answer
\begin{verbatim}
-> print(summary(fmPQR <- fastLm(y ~ f1*f2, dd)), signif.st=FALSE)
+R> print(summary(fmPQR <- fastLm(y ~ f1*f2, dd)), signif.st=FALSE)
Call:
fastLm.formula(formula = y ~ f1 * f2, data = dd)
@@ -1201,11 +1202,11 @@
Residual standard error: 0.2868 on 11 degrees of freedom
Multiple R-squared: 0.9999, Adjusted R-squared: 0.9999
-> all.equal(coef(fm1), coef(fmPQR))
+R> all.equal(coef(fm1), coef(fmPQR))
[1] TRUE
-> all.equal(unname(fitted(fm1)), fitted(fmPQR))
+R> all.equal(unname(fitted(fm1)), fitted(fmPQR))
[1] TRUE
-> all.equal(unname(residuals(fm1)), residuals(fmPQR))
+R> all.equal(unname(residuals(fm1)), residuals(fmPQR))
[1] TRUE
\end{verbatim}
@@ -1213,7 +1214,7 @@
values but not the same coefficients.
\begin{verbatim}
-> print(summary(fmSVD <- fastLm(y ~ f1*f2, dd, method=4)), signif.st=FALSE)
+R> print(summary(fmSVD <- fastLm(y ~ f1*f2, dd, method=4)), signif.st=FALSE)
Call:
fastLm.formula(formula = y ~ f1 * f2, data = dd, method = 4)
@@ -1234,11 +1235,11 @@
Residual standard error: 0.2868 on 11 degrees of freedom
Multiple R-squared: 0.9999, Adjusted R-squared: 0.9999
-> all.equal(coef(fm1), coef(fmSVD))
+R> all.equal(coef(fm1), coef(fmSVD))
[1] "'is.NA' value mismatch: 0 in current 1 in target"
-> all.equal(unname(fitted(fm1)), fitted(fmSVD))
+R> all.equal(unname(fitted(fm1)), fitted(fmSVD))
[1] TRUE
-> all.equal(unname(residuals(fm1)), residuals(fmSVD))
+R> all.equal(unname(residuals(fm1)), residuals(fmSVD))
[1] TRUE
\end{verbatim}
@@ -1247,8 +1248,8 @@
be the same for these two methods.
\begin{verbatim}
-> summary(fmVLV <- fastLm(y ~ f1*f2, dd, method=5))
-> all.equal(coef(fmSVD), coef(fmVLV))
+R> summary(fmVLV <- fastLm(y ~ f1*f2, dd, method=5))
+R> all.equal(coef(fmSVD), coef(fmVLV))
[1] TRUE
\end{verbatim}
@@ -1270,7 +1271,7 @@
It can be run as
\begin{verbatim}
-> source(system.file("examples", "lmBenchmark.R", package="RcppEigen"))
+R> source(system.file("examples", "lmBenchmark.R", package="RcppEigen"))
\end{verbatim}
Results will vary according to the speed of the processor and the
implementation of the BLAS (Basic Linear Algebra Subroutines) used.
@@ -1409,14 +1410,14 @@
\label{badtrans}
\end{figure}
\begin{verbatim}
-> Ai <- matrix(1:6, ncol=2L)
-> ftrans2 <- cxxfunction(signature(AA = "matrix"),
-+ badtransCpp, "RcppEigen", incl)
-> (At <- ftrans2(Ai))
+R> Ai <- matrix(1:6, ncol=2L)
+R> ftrans2 <- cxxfunction(signature(AA = "matrix"),
++ badtransCpp, "RcppEigen", incl)
+R> (At <- ftrans2(Ai))
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6
-> all.equal(At, t(Ai))
+R> all.equal(At, t(Ai))
[1] "Mean relative difference: 0.4285714"
\end{verbatim}
@@ -1451,12 +1452,12 @@
\end{figure}
\begin{verbatim}
-> sparse1 <- cxxfunction(signature(AA = "dgCMatrix", yy = "numeric"),
-+ sparseProdCpp, "RcppEigen", incl)
-> data(KNex, package="Matrix")
-> rr <- sparse1(KNex$mm, KNex$y)
-> stopifnot(all.equal(rr$At, t(KNex$mm)),
-+ all.equal(rr$Aty, as.vector(crossprod(KNex$mm, KNex$y))))
+R> sparse1 <- cxxfunction(signature(AA = "dgCMatrix", yy = "numeric"),
++ sparseProdCpp, "RcppEigen", incl)
+R> data(KNex, package="Matrix")
+R> rr <- sparse1(KNex$mm, KNex$y)
+R> stopifnot(all.equal(rr$At, t(KNex$mm)),
++ all.equal(rr$Aty, as.vector(crossprod(KNex$mm, KNex$y))))
\end{verbatim}
Sparse Cholesky decompositions are provided by the
@@ -1498,9 +1499,9 @@
\end{figure}
\begin{verbatim}
-> sparse2 <- cxxfunction(signature(AA = "dgCMatrix", yy = "numeric"),
-+ sparseLSCpp, "RcppEigen", incl)
-> str(rr <- sparse2(KNex$mm, KNex$y))
+R> sparse2 <- cxxfunction(signature(AA = "dgCMatrix", yy = "numeric"),
++ sparseLSCpp, "RcppEigen", incl)
+R> str(rr <- sparse2(KNex$mm, KNex$y))
List of 4
$ L :Formal class 'dCHMsimpl' [package "Matrix"] with 10 slots
.. ..@ x : num [1:7395] 1 0.0919 -0.1241 -0.0984 1 ...
@@ -1516,14 +1517,14 @@
$ betahatS: num [1:712] 823 340 473 349 188 ...
$ betahatC: num [1:712] 823 340 473 349 188 ...
$ perm : int [1:712] 120 334 118 332 331 489 333 490 340 131 ...
-> res <- as.vector(solve(Ch <- Cholesky(crossprod(KNex$mm)),
-+ crossprod(KNex$mm, KNex$y)))
-> stopifnot(all.equal(rr$betahatS, res), all.equal(rr$betahatC, res))
-> # factors are different sizes
-> c(nnzL=length(rr$L at x), nnzCh=length(Ch at x))
+R> res <- as.vector(solve(Ch <- Cholesky(crossprod(KNex$mm)),
++ crossprod(KNex$mm, KNex$y)))
+R> stopifnot(all.equal(rr$betahatS, res), all.equal(rr$betahatC, res))
+R> # factors are different sizes
+R> c(nnzL=length(rr$L at x), nnzCh=length(Ch at x))
nnzL nnzCh
7395 7451
-> all(rr$perm == Ch at perm) # fill-reducing permutations are different
+R> all(rr$perm == Ch at perm) # fill-reducing permutations are different
[1] FALSE
\end{verbatim}
More information about the Rcpp-commits
mailing list