[Rcpp-commits] r1339 - in pkg/RcppGSL/inst: . doc
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu May 27 13:08:57 CEST 2010
Author: edd
Date: 2010-05-27 13:08:57 +0200 (Thu, 27 May 2010)
New Revision: 1339
Modified:
pkg/RcppGSL/inst/ChangeLog
pkg/RcppGSL/inst/doc/RcppGSL.Rnw
Log:
minor reformatting/redindenting in Changelog
few small changes in vignette
Modified: pkg/RcppGSL/inst/ChangeLog
===================================================================
--- pkg/RcppGSL/inst/ChangeLog 2010-05-27 11:06:56 UTC (rev 1338)
+++ pkg/RcppGSL/inst/ChangeLog 2010-05-27 11:08:57 UTC (rev 1339)
@@ -1,32 +1,33 @@
2010-05-25 Romain Francois <romain at r-enthusiasts.com>
- * inst/include/RcppGSLForward.h : add indexing operator, stl iterator and
- begin() and end() methods to RcppGSL::vector using proxy classes
-
- * inst/include/RcppGSLForward.h : RcppGSL::matrix gets indexing
+ * inst/include/RcppGSLForward.h : add indexing operator, stl iterator
+ and begin() and end() methods to RcppGSL::vector using proxy classes
+
+ * inst/include/RcppGSLForward.h : RcppGSL::matrix gets indexing
operator(int,int)
-
- * configure.win: added empty configure.win so that R CMD check does not
- get jealous about the configure script
-
+
+ * configure.win: added empty configure.win so that R CMD check does
+ not get jealous about the configure script
+
* src/Makevars.win: use Brian Ripley's suggestions to anticipate R 2.12.0
* inst/include/*.h: RcppGSL::vector_view and RcppGSL::matrix_view
-
+
2010-05-13 Dirk Eddelbuettel <edd at debian.org>
* R/fastLm.R: fastLm is now generic and behaves similar to lm():
formula interface, returns object of class 'fastLm', and had methods
for print, summary and predict
* man/fasttLm.Rd: documented interface accordingly
- * src/fastLm.cpp: Added covariance matrix and degrees of freedom to
- list of result returned from C++ to R
+ * src/fastLm.cpp: Added and degrees of freedom to list of result
+ returned from C++ to R
2010-05-13 Romain Francois <romain at r-enthusiasts.com>
* inst/include/*.h: wrap specializations are now inline
- * inst/include/*.h: new classes RcppGSL::matrix<T> and RcppGSL::matrix_view<T>
+ * inst/include/*.h: new classes RcppGSL::matrix<T> and
+ RcppGSL::matrix_view<T>
2010-05-12 Dirk Eddelbuettel <edd at debian.org>
@@ -34,8 +35,8 @@
2010-05-12 Romain Francois <romain at r-enthusiasts.com>
- * inst/include/*.h: added classes RcppGSL::vector<T> that act as smart pointers
- to gsl_vector_* objects. This gives nicer syntax and helps Rcpp implicit
- converters wrap and as.
+ * inst/include/*.h: added classes RcppGSL::vector<T> that act as
+ smart pointers to gsl_vector_* objects. This gives nicer syntax and
+ helps Rcpp implicit converters wrap and as.
Modified: pkg/RcppGSL/inst/doc/RcppGSL.Rnw
===================================================================
--- pkg/RcppGSL/inst/doc/RcppGSL.Rnw 2010-05-27 11:06:56 UTC (rev 1338)
+++ pkg/RcppGSL/inst/doc/RcppGSL.Rnw 2010-05-27 11:08:57 UTC (rev 1339)
@@ -25,20 +25,29 @@
\abstract{
\noindent
- The GNU Scientific Library \texttt{GSL} is a numerical library for
+ The GNU Scientific Library \texttt{GSL} is a numerical library for
C and C++ programmers. It is free software under the GNU General Public License.
- The library provides a wide range of mathematical routines such as random number
- generators, special functions and least-squares fitting.
+ The library provides a wide range of mathematical routines such as random number
+ generators, special functions and least-squares fitting.
There are over 1000 functions in total with an extensive test suite.
-
- The \texttt{RcppGSL} package is a simple package that provides a bridge
- between \texttt{GSL} data structures and \texttt{Rcpp} concepts.
+
+ The \texttt{RcppGSL} package provides an easy-to-use interface
+ between \texttt{GSL} data structures and concepts from \texttt{Rcpp} which
+ is itself a package that eases the interfaces between R and C++.
}
-\section{vectors}
+\section{Introduction}
-\subsection{gsl vectors}
+TODO
+\section{Motivation: FastLm}
+
+TODO: Show FastLm() to show what this can be used for.
+
+\section{Vectors}
+
+\subsection{GSL Vectors}
+
\texttt{GSL} defines various vector types to manipulate one-dimensionnal
data, similar to R arrays. For example the \verb|gsl_vector| and \verb|gsl_vector_int|
structs are defined as:
@@ -58,13 +67,13 @@
int *data;
gsl_block_int *block;
int owner;
-}
+}
gsl_vector_int;
\end{verbatim}
-A typical use of the \verb|gsl_vector| struct is given below:
+A typical use of the \verb|gsl_vector| struct is given below:
-\begin{verbatim}
+\begin{verbatim}
int i;
// allocate a gsl_vector of size 3
@@ -88,10 +97,10 @@
\subsection{RcppGSL::vector}
\texttt{RcppGSL} defines the template \texttt{RcppGSL::vector<T>} to manipulate
-\verb|gsl_vector| pointers taking advantage of C++ templates. Using the
-template the previous example becomes:
+\verb|gsl_vector| pointers taking advantage of C++ templates. Using the
+template the previous example becomes:
-\begin{verbatim}
+\begin{verbatim}
int i;
// allocate a gsl_vector of size 3
@@ -113,15 +122,15 @@
\end{verbatim}
The class \texttt{RcppGSL::vector<double>} is a smart pointer, that can be used
-anywhere where a raw pointer \verb|gsl_vector| can be used, such as the
-\verb|gsl_vector_set| and \verb|gsl_vector_get| functions above.
+anywhere where a raw pointer \verb|gsl_vector| can be used, such as the
+\verb|gsl_vector_set| and \verb|gsl_vector_get| functions above.
-Beyond the convenience of a nicer syntax for allocation and release of memory,
+Beyond the convenience of a nicer syntax for allocation and release of memory,
the \texttt{RcppGSL::vector} template faciliates interchange of \texttt{GSL}
vectors with \texttt{Rcpp} concepts. The following example defines a \texttt{.Call}
compatible function called \verb|sum_gsl_vector_int|
that operates on a \verb|gsl_vector_int| through the \texttt{RcppGSL::vector<int>}
-template specialization:
+template specialization:
\begin{verbatim}
RCPP_FUNCTION_1( int, sum_gsl_vector_int, RcppGSL::vector<int> vec){
@@ -132,15 +141,15 @@
}
\end{verbatim}
-The function can then simply be called from R :
+The function can then simply be called from R :
\begin{verbatim}
> .Call( "sum_gsl_vector_int", 1:10 )
[1] 55
\end{verbatim}
-A second example shows a simple function that grabs elements of an
-R list as \verb|gsl_vector| objects using implicit conversion mechanisms
+A second example shows a simple function that grabs elements of an
+R list as \verb|gsl_vector| objects using implicit conversion mechanisms
of Rcpp
\begin{verbatim}
@@ -148,7 +157,7 @@
// grab "x" as a gsl_vector through
// the RcppGSL::vector<double> class
RcppGSL::vector<double> x = data["x"] ;
-
+
// grab "y" as a gsl_vector through
// the RcppGSL::vector<int> class
RcppGSL::vector<int> y = data["y"] ;
@@ -156,12 +165,12 @@
for( int i=0; i< x->size; i++){
res += x[i] * y[i] ;
}
-
- // as usual with GSL, we need to explicitely free the
+
+ // as usual with GSL, we need to explicitely free the
// memory
- x.free() ;
+ x.free() ;
y.free() ;
-
+
// return the result
return res ;
}
@@ -186,18 +195,18 @@
gsl vector & RcppGSL \\
\hline
\texttt{gsl\_vector} & \texttt{RcppGSL::vector<double>} \\
-\texttt{gsl\_vector\_int} & \texttt{RcppGSL::vector<int>} \\
-\texttt{gsl\_vector\_float} & \texttt{RcppGSL::vector<float>} \\
-\texttt{gsl\_vector\_long} & \texttt{RcppGSL::vector<long>} \\
-\texttt{gsl\_vector\_char} & \texttt{RcppGSL::vector<char>} \\
-\texttt{gsl\_vector\_complex} & \texttt{RcppGSL::vector<gsl\_complex>} \\
-\texttt{gsl\_vector\_complex\_float} & \texttt{RcppGSL::vector<gsl\_complex\_float>} \\
-\texttt{gsl\_vector\_complex\_long\_double} & \texttt{RcppGSL::vector<gsl\_complex\_long\_double>} \\
-\texttt{gsl\_vector\_long\_double} & \texttt{RcppGSL::vector<long double>} \\
-\texttt{gsl\_vector\_short} & \texttt{RcppGSL::vector<short>} \\
-\texttt{gsl\_vector\_uchar} & \texttt{RcppGSL::vector<unsigned char>} \\
-\texttt{gsl\_vector\_uint} & \texttt{RcppGSL::vector<unsigned int>} \\
-\texttt{gsl\_vector\_ushort} & \texttt{RcppGSL::vector<insigned short>} \\
+\texttt{gsl\_vector\_int} & \texttt{RcppGSL::vector<int>} \\
+\texttt{gsl\_vector\_float} & \texttt{RcppGSL::vector<float>} \\
+\texttt{gsl\_vector\_long} & \texttt{RcppGSL::vector<long>} \\
+\texttt{gsl\_vector\_char} & \texttt{RcppGSL::vector<char>} \\
+\texttt{gsl\_vector\_complex} & \texttt{RcppGSL::vector<gsl\_complex>} \\
+\texttt{gsl\_vector\_complex\_float} & \texttt{RcppGSL::vector<gsl\_complex\_float>} \\
+\texttt{gsl\_vector\_complex\_long\_double} & \texttt{RcppGSL::vector<gsl\_complex\_long\_double>} \\
+\texttt{gsl\_vector\_long\_double} & \texttt{RcppGSL::vector<long double>} \\
+\texttt{gsl\_vector\_short} & \texttt{RcppGSL::vector<short>} \\
+\texttt{gsl\_vector\_uchar} & \texttt{RcppGSL::vector<unsigned char>} \\
+\texttt{gsl\_vector\_uint} & \texttt{RcppGSL::vector<unsigned int>} \\
+\texttt{gsl\_vector\_ushort} & \texttt{RcppGSL::vector<insigned short>} \\
\texttt{gsl\_vector\_ulong} & \texttt{RcppGSL::vector<unsigned long>} \\
\hline
@@ -207,33 +216,33 @@
in RcppGSL.}
\end{table}
-\section{vector views}
+\section{ Vector Views}
Several \texttt{GSL} algorithms return GSL vector views as result. \texttt{RcppGSL}
-defines the template class \texttt{RcppGSL::vector\_view} to handle
-vector views using C++ syntax.
+defines the template class \texttt{RcppGSL::vector\_view} to handle
+vector views using C++ syntax.
\begin{verbatim}
extern "C" SEXP test_gsl_vector_view(){
int n = 10 ;
RcppGSL::vector<double> v(n) ;
for( int i=0 ; i<n; i++){
- v[i] = i ;
+ v[i] = i ;
}
RcppGSL::vector_view<double> v_even = gsl_vector_subvector_with_stride(v, 0, 2, n/2);
RcppGSL::vector_view<double> v_odd = gsl_vector_subvector_with_stride(v, 1, 2, n/2);
-
- List res = List::create(
- _["even"] = v_even,
+
+ List res = List::create(
+ _["even"] = v_even,
_["odd" ] = v_odd
) ;
v.free() ;
-
+
return res ;
}
\end{verbatim}
-As with vectors, c++ objects \texttt{RcppGSL::vector\_view} can be implicitely
+As with vectors, c++ objects \texttt{RcppGSL::vector\_view} can be implicitely
converted to their associated gsl view type, as listed in table \ref{tabviews}
so that they can be passed to compatible gsl algorithms.
@@ -245,20 +254,20 @@
gsl vector views & RcppGSL \\
\hline
\texttt{gsl\_vector\_view} & \texttt{RcppGSL::vector\_view<double>} \\
-\texttt{gsl\_vector\_view\_int} & \texttt{RcppGSL::vector\_view<int>} \\
-\texttt{gsl\_vector\_view\_float} & \texttt{RcppGSL::vector\_view<float>} \\
-\texttt{gsl\_vector\_view\_long} & \texttt{RcppGSL::vector\_view<long>} \\
-\texttt{gsl\_vector\_view\_char} & \texttt{RcppGSL::vector\_view<char>} \\
-\texttt{gsl\_vector\_view\_complex} & \texttt{RcppGSL::vector\_view<gsl\_complex>} \\
-\texttt{gsl\_vector\_view\_complex\_float} & \texttt{RcppGSL::vector\_view<gsl\_complex\_float>} \\
-\texttt{gsl\_vector\_view\_complex\_long\_double} & \texttt{RcppGSL::vector\_view<gsl\_complex\_long\_double>} \\
-\texttt{gsl\_vector\_view\_long\_double} & \texttt{RcppGSL::vector\_view<long double>} \\
-\texttt{gsl\_vector\_view\_short} & \texttt{RcppGSL::vector\_view<short>} \\
-\texttt{gsl\_vector\_view\_uchar} & \texttt{RcppGSL::vector\_view<unsigned char>} \\
-\texttt{gsl\_vector\_view\_uint} & \texttt{RcppGSL::vector\_view<unsigned int>} \\
-\texttt{gsl\_vector\_view\_ushort} & \texttt{RcppGSL::vector\_view<insigned short>} \\
+\texttt{gsl\_vector\_view\_int} & \texttt{RcppGSL::vector\_view<int>} \\
+\texttt{gsl\_vector\_view\_float} & \texttt{RcppGSL::vector\_view<float>} \\
+\texttt{gsl\_vector\_view\_long} & \texttt{RcppGSL::vector\_view<long>} \\
+\texttt{gsl\_vector\_view\_char} & \texttt{RcppGSL::vector\_view<char>} \\
+\texttt{gsl\_vector\_view\_complex} & \texttt{RcppGSL::vector\_view<gsl\_complex>} \\
+\texttt{gsl\_vector\_view\_complex\_float} & \texttt{RcppGSL::vector\_view<gsl\_complex\_float>} \\
+\texttt{gsl\_vector\_view\_complex\_long\_double} & \texttt{RcppGSL::vector\_view<gsl\_complex\_long\_double>} \\
+\texttt{gsl\_vector\_view\_long\_double} & \texttt{RcppGSL::vector\_view<long double>} \\
+\texttt{gsl\_vector\_view\_short} & \texttt{RcppGSL::vector\_view<short>} \\
+\texttt{gsl\_vector\_view\_uchar} & \texttt{RcppGSL::vector\_view<unsigned char>} \\
+\texttt{gsl\_vector\_view\_uint} & \texttt{RcppGSL::vector\_view<unsigned int>} \\
+\texttt{gsl\_vector\_view\_ushort} & \texttt{RcppGSL::vector\_view<insigned short>} \\
\texttt{gsl\_vector\_view\_ulong} & \texttt{RcppGSL::vector\_view<unsigned long>} \\
-
+
\hline
\end{tabular}
\end{small}
@@ -267,7 +276,7 @@
\end{table}
-\section{matrices}
+\section{Matrices}
TODO: write content about \texttt{RcppGSL::matrix} and \texttt{RcppGSL::matrix\_view}
More information about the Rcpp-commits
mailing list