|
MuGen
Multitrait genetics
|
R interface for GSL binary file format. More...
#include <R.h>#include <string>#include <iostream>#include <algorithm>#include <gsl/gsl_matrix.h>#include <gsl/gsl_vector.h>Functions | |
| void | GSLmatSave (const char **fileNam, const double *vec, const int *nRows, const int *nCols) |
| Save a double-precision matrix. More... | |
| void | GSLvecSaveInt (const char **fileNam, const int *vec, const int *len) |
| Save a vector of integers. More... | |
| void | GSLvecSave (const char **fileNam, const double *vec, const int *len) |
| Save a double-precision vector. More... | |
| void | GSLvecAppend (const char **fileNam, const double *vec, const int *len) |
| Appending a double-precision vector to an existing file. More... | |
| void | GSLiVecLoad (const char **fileNam, const int *len, int *arr) |
| Read a vector of integers. More... | |
| void | GSLmatLoad (const char **fileNam, const int *nRows, const int *nCols, double *arr) |
| Read a double-precision array or matrix. More... | |
R interface for GSL binary file format.
Functions to read and write binary files saved in GSL binary format from R.
To compile, run on command line:
R CMD SHLIB GSLRIO.cpp -lgsl -O3 -DHAVE_INLINE -DGSL_RANGE_CHECK_OFF
and put the resulting GSLRIO.o where it can be found by dyn.load() in R. The functions are then ready to use with the .C() command.
.C(), the corresponding arguments (here they are file names) must be in the form **fileNam. | void GSLiVecLoad | ( | const char ** | fileNam, |
| const int * | len, | ||
| int * | arr | ||
| ) |
Read a vector of integers.
Reading a file into an array of integers.
| [in] | char** | output file name |
| [in] | int* | pointer to array length |
| [out] | int* | array of integers to be passed to R |
| void GSLmatLoad | ( | const char ** | fileNam, |
| const int * | nRows, | ||
| const int * | nCols, | ||
| double * | arr | ||
| ) |
Read a double-precision array or matrix.
Reads a double-precision array (vector) or matrix. If a vector is desired, one of the dimensions should be set to one. The matrix is stored by row, so make sure to use matrix(..., byrow = T) in the R code.
| [in] | char** | output file name |
| [in] | int* | pointer to the number of rows |
| [in] | int* | pointer to the number of columns |
| [out] | double* | array to be passed to R and converted to a matrix if necessary |
| void GSLmatSave | ( | const char ** | fileNam, |
| const double * | vec, | ||
| const int * | nRows, | ||
| const int * | nCols | ||
| ) |
Save a double-precision matrix.
The fact that R matrices are column-major, while in C/C++ they are row-major is dealt with internally. The R user does not have to worry about that.
| [in] | char** | output file name |
| [in] | double* | vectorized matrix to be saved |
| [in] | int* | pointer to the number of rows |
| [in] | int* | pointer to the number of columns |
| void GSLvecAppend | ( | const char ** | fileNam, |
| const double * | vec, | ||
| const int * | len | ||
| ) |
Appending a double-precision vector to an existing file.
| [in] | char** | output file name |
| [in] | double* | double-precision array |
| [in] | int* | pointer to the array size |
| void GSLvecSave | ( | const char ** | fileNam, |
| const double * | vec, | ||
| const int * | len | ||
| ) |
Save a double-precision vector.
| [in] | char** | output file name |
| [in] | double* | double-precision array |
| [in] | int* | pointer to the array size |
| void GSLvecSaveInt | ( | const char ** | fileNam, |
| const int * | vec, | ||
| const int * | len | ||
| ) |
Save a vector of integers.
Typically used to save index (factor) vectors to read into RanIndex objects.
| [in] | char** | output file name |
| [in] | int* | array of integers |
| [in] | int* | pointer to the array length |