Ergebnis für URL: http://dirk.eddelbuettel.com/code/rcpp.gsl.html [1]Dirk Eddelbuettel
* [2]Blog
* [3]Code
* [4]Publications
* [5]Talks
* [6]Other
+ [7]Rcpp (local page)
+ [8]Rcpp website
+ [9]RInside
+ [10]RQuantLib
+ [11]CRANberries
+ [12]R/Finance Conferences
+ [13]Quantian
+ [14]Site map
RcppGSL: Rcpp Integration for GNU GSL Vectors and Matrices
[15]Build Status [16]License [17]CRAN [18]Debian package [19]Downloads [20]Last
Commit
RcppGSL provides an interface from R to the vector and matrix classes of the
[21]GNU GSL, a collection of numerical routines for scientifc computing.
It is particularly useful for C and C++ programs as it provides a standard C
interface to a wide range of mathematical routines such as special functions,
permutations, combinations, fast fourier transforms, eigensystems, random
numbers, quadrature, random distributions, quasi-random sequences, Monte Carlo
integration, N-tuples, differential equations, simulated annealing, numerical
differentiation, interpolation, series acceleration, Chebyshev approximations,
root-finding, discrete Hankel transforms physical constants, basis splines and
wavelets. There are over 1000 functions in total with an extensive test suite.
The RcppGSL package provides an easy-to-use interface between GSL data structures
and [22]GNU R using concepts from [23]Rcpp which is itself a package that eases
the interfaces between R and C++.
What can RcppGSL do?
The RcppGSL package does a few things, in particular for vectors and matrices:
* templated vector and matrix classes: these are similar to Rcpp's own vector
and matrix classes, but really are just smart pointers around the C structure
expected by the library
* this means you can transfer data from R to your GSL-using programs in pretty
much the same way you would in other C++ programs using Rcpp--by relying on
the Rcpp::as() and Rcpp::wrap() converterrs which are most often invoked
automatically for you anyway
* at the C++ level you can use these GSL vectors in a more C++-alike way (using
eg foo[i] to access an element at index i)
* yet at the same time you can just pass these vector and matrix objects to the
GSL functions expecting its C objects: thanks to some cleverness in these
classes they pass the right object on (see the example below)
* we also provide the lightweight views for vectors and matrices as the GSL API
uses these in many places.
In sum, these features aim to make it a lot easier to use functionality from the
(excellent) [24]GNU GSL in a way that is more natural to a user of C++ and R (and
of course [25]Rcpp) The [26]package vignette. has a more details.
So give me an example!
Here is a simple implementation of a column norm (which we could easily compute
directly in R, but we are simply re-using an example from [27]Section 8.4.14 of
the GSL manual).
#include
#include
#include
// [[Rcpp::export]]
Rcpp::NumericVector colNorm(const RcppGSL::Matrix & G) {
int k = G.ncol();
Rcpp::NumericVector n(k); // to store results
for (int j = 0; j < k; j++) {
RcppGSL::VectorView colview = gsl_matrix_const_column (G, j);
n[j] = gsl_blas_dnrm2(colview);
}
return n; // return vector
}
This example shows how a RcppGSL::Matrix object (a typedef shortcut to the
templated double representation) gets passed down from R; we can use standard
const & interface as well. Inside the function we then read the number of columns
from a member function ncol() (using the same name as in R). We assign a standard
[28]Rcpp vector of the corresponding size k to hold the result which is returned
to R.
To compute the column norms, we loop over all columns. The norm is computed after
we extract a column as a const view (see the GSL manual for details: this is
essentially a lightweight slice referring back to the original object). This
column can be passed directly to a GSL function expecting a vector - very nice.
The actual computation is done by a standard GSL function, here gsl_blas_dnrm2,
which expects a standard GSL vector - which our classes transparently provide in
this context.
Previous versions then had to free the memory of the matrix object; this is now
done automagically. By using Rcpp Attributes, all this is wrapped in a try/catch
block as is standard with [29]Rcpp.
Another example function for a faster compiled implementation of lm() using the
model fitting code in the GSL is also included in the package.
Where do I get it
RcppGSL is a [30]CRAN package, lives otherwise in its own habitat at [31]GitHub
and can also be downloaded from the local [32]Rcpp archive which also has a copy
of the [33]vignette describing the package.
Authors
RcppGSL is being written by Dirk Eddelbuettel and Romain Francois using [34]Rcpp.
License
RcppGSL is licensed under the GNU GPL version 2 or later.
Initially created: Thu Mar 11 11:14:31 CST 2010
Last modified: Fri Jul 31 16:12:54 CDT 2020
[INS: :INS]
[INS: :INS]
References
Visible links:
1. https://dirk.eddelbuettel.com/
2. https://dirk.eddelbuettel.com/blog/
3. https://dirk.eddelbuettel.com/code/
4. https://dirk.eddelbuettel.com/papers.html
5. https://dirk.eddelbuettel.com/presentations.html
6. http://dirk.eddelbuettel.com/code/rcpp.gsl.html
7. https://dirk.eddelbuettel.com/code/rcpp.html
8. http://www.rcpp.org/
9. https://dirk.eddelbuettel.com/code/rinside.html
10. https://dirk.eddelbuettel.com/code/rquantlib.html
11. https://dirk.eddelbuettel.com/cranberries/
12. http://www.rinfinance.com/
13. https://dirk.eddelbuettel.com/quantian.html
14. https://dirk.eddelbuettel.com/site.html
15. https://travis-ci.org/eddelbuettel/rcppgsl
16. http://www.gnu.org/licenses/gpl-2.0.html
17. https://cran.r-project.org/package=RcppGSL
18. https://packages.debian.org/sid/r-cran-rcppgsl
19. http://www.r-pkg.org/pkg/RcppGSL
20. https://github.com/eddelbuettel/rcppgsl
21. http://www.gnu.org/software/gsl
22. http://www.r-project.org/
23. http://dirk.eddelbuettel.com/code/rcpp.html
24. http://www.gnu.org/software/gsl/
25. http://dirk.eddelbuettel.com/code/rcpp.html
26. http://dirk.eddelbuettel.com/code/rcpp/RcppGSL-intro.pdf
27. http://www.gnu.org/software/gsl/manual/html_node/Example-programs-for-matrices.html
28. http://dirk.eddelbuettel.com/code/rcpp.html
29. http://dirk.eddelbuettel.com/code/rcpp.html
30. http://cran.r-project.org/package=RcppGSL
31. https://github.com/eddelbuettel/rcppgsl
32. http://dirk.eddelbuettel.com/code/rcpp/
33. http://dirk.eddelbuettel.com/code/rcpp/RcppGSL.pdf
34. http://dirk.eddelbuettel.com/code/rcpp.html
Hidden links:
36. http://dirk.eddelbuettel.com/code/rcpp.gsl.html#cb1-1
37. http://dirk.eddelbuettel.com/code/rcpp.gsl.html#cb1-2
38. http://dirk.eddelbuettel.com/code/rcpp.gsl.html#cb1-3
39. http://dirk.eddelbuettel.com/code/rcpp.gsl.html#cb1-4
40. http://dirk.eddelbuettel.com/code/rcpp.gsl.html#cb1-5
41. http://dirk.eddelbuettel.com/code/rcpp.gsl.html#cb1-6
42. http://dirk.eddelbuettel.com/code/rcpp.gsl.html#cb1-7
43. http://dirk.eddelbuettel.com/code/rcpp.gsl.html#cb1-8
44. http://dirk.eddelbuettel.com/code/rcpp.gsl.html#cb1-9
45. http://dirk.eddelbuettel.com/code/rcpp.gsl.html#cb1-10
46. http://dirk.eddelbuettel.com/code/rcpp.gsl.html#cb1-11
47. http://dirk.eddelbuettel.com/code/rcpp.gsl.html#cb1-12
48. http://dirk.eddelbuettel.com/code/rcpp.gsl.html#cb1-13
49. http://dirk.eddelbuettel.com/code/rcpp.gsl.html#cb1-14
50. http://twitter.com/eddelbuettel
51. https://github.com/eddelbuettel
52. http://www.linkedin.com/in/dirkeddelbuettel/
53. http://dirk.eddelbuettel.com/
Usage: http://www.kk-software.de/kklynxview/get/URL
e.g. http://www.kk-software.de/kklynxview/get/http://www.kk-software.de
Errormessages are in German, sorry ;-)