All Projects → eddelbuettel → rcppgsl

eddelbuettel / rcppgsl

Licence: other
Rcpp integration for GNU GSL vectors and matrices

Programming Languages

C++
36643 projects - #6 most used programming language
r
7636 projects
M4
1887 projects

Projects that are alternatives of or similar to rcppgsl

rcppfastfloat
Rcpp Bindings for the 'fastfloat' Header-Only Library
Stars: ✭ 18 (-35.71%)
Mutual labels:  cran, rcpp, r-package
inline
Inline C, C++ or Fortran functions in R
Stars: ✭ 33 (+17.86%)
Mutual labels:  cran, rcpp, r-package
WeightedTreemaps
Create Voronoi and Sunburst Treemaps from Hierarchical data
Stars: ✭ 33 (+17.86%)
Mutual labels:  rcpp, r-package
pkgkitten
Create simple packages which pass R CMD check
Stars: ✭ 31 (+10.71%)
Mutual labels:  cran, r-package
xfun
Miscellaneous R functions
Stars: ✭ 102 (+264.29%)
Mutual labels:  cran, r-package
TDAstats
R pipeline for computing persistent homology in topological data analysis. See https://doi.org/10.21105/joss.00860 for more details.
Stars: ✭ 26 (-7.14%)
Mutual labels:  cran, r-package
worldfootballR
A wrapper for extracting world football (soccer) data from FBref, Transfermark, Understat and fotmob
Stars: ✭ 188 (+571.43%)
Mutual labels:  cran, r-package
heddlr
Bring a functional programming mindset to R Markdown document generation
Stars: ✭ 14 (-50%)
Mutual labels:  cran, r-package
rcppmsgpack
MsgPack Headers for R / msgpack.org[R]
Stars: ✭ 17 (-39.29%)
Mutual labels:  cran, r-package
pbapply
Adding progress bar to '*apply' functions in R
Stars: ✭ 115 (+310.71%)
Mutual labels:  cran, r-package
FLightR
R package to position animals with solar geolocation archival tags
Stars: ✭ 16 (-42.86%)
Mutual labels:  cran, r-package
PackageDevelopment
Task View: PackageDevelopment
Stars: ✭ 38 (+35.71%)
Mutual labels:  cran, r-package
BAS
BAS R package https://merliseclyde.github.io/BAS/
Stars: ✭ 36 (+28.57%)
Mutual labels:  cran, r-package
nflfastR
A Set of Functions to Efficiently Scrape NFL Play by Play Data
Stars: ✭ 268 (+857.14%)
Mutual labels:  cran, r-package
vioplot
Development version of vioplot R package (CRAN maintainer)
Stars: ✭ 25 (-10.71%)
Mutual labels:  cran, r-package
rprotobuf
R Interface to Protocol Buffers
Stars: ✭ 62 (+121.43%)
Mutual labels:  cran, r-package
bh
R package providing Boost Header files
Stars: ✭ 73 (+160.71%)
Mutual labels:  rcpp, r-package
RcppXPtrUtils
XPtr Add-Ons for 'Rcpp'
Stars: ✭ 17 (-39.29%)
Mutual labels:  cran, rcpp
qwraps2
An updated version of qwraps with a focus on flexibility and general purpose. These functions are helpful for extracting and formatting results from R into .Rnw or .Rmd files. Additional functions for routine work such as extracting results from regression models or finding sensitivity and specificity.
Stars: ✭ 33 (+17.86%)
Mutual labels:  cran, r-package
jpndistrict
🗾 Create Japansese Administration Area Maps
Stars: ✭ 18 (-35.71%)
Mutual labels:  cran, r-package

RcppGSL: Rcpp Integration for GNU GSL Vectors and Matrices

CI License CRAN Debian package Downloads Last Commit

This package uses Rcpp to connect the R system to the GNU GSL, a collection of numerical routines for scientific computing, particularly its vector and matrix classes.

Examples

Faster lm() for OLS regression

The fastLm() function included as file src/fastLm.cpp in the package:

#include <RcppGSL.h>

#include <gsl/gsl_multifit.h>
#include <cmath>

// [[Rcpp::export]]
Rcpp::List fastLm(const RcppGSL::Matrix &X, const RcppGSL::Vector &y) {

    int n = X.nrow(), k = X.ncol();
    double chisq;

    RcppGSL::Vector coef(k);                // to hold the coefficient vector 
    RcppGSL::Matrix cov(k,k);               // and the covariance matrix
    
    // the actual fit requires working memory we allocate and free
    gsl_multifit_linear_workspace *work = gsl_multifit_linear_alloc (n, k);
    gsl_multifit_linear (X, y, coef, cov, &chisq, work);
    gsl_multifit_linear_free (work);

    // assign diagonal to a vector, then take square roots to get std.error
    Rcpp::NumericVector std_err;
    std_err = gsl_matrix_diagonal(cov); 	// need two step decl. and assignment
    std_err = Rcpp::sqrt(std_err);         	// sqrt() is an Rcpp sugar function

    return Rcpp::List::create(Rcpp::Named("coefficients") = coef, 
                              Rcpp::Named("stderr")       = std_err,
                              Rcpp::Named("df.residual")  = n - k);
    
}

A simple column norm

This example comes from the complete example package included in RcppGSL and is from the file inst/examples/RcppGSLExample/src/colNorm.cpp

#include <RcppGSL.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_blas.h>

// [[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
}

Dependencies

Availabililty

On CRAN and here.

Authors

Dirk Eddelbuettel and Romain Francois

License

GPL (>= 2)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].