13#include <gsl/gsl_errno.h>
15#include "GSLUtility.h"
16#include "IException.h"
174 for(
size_t i = 0 ; i < n ; i++) {
190 size_t nrows =
Rows(m);
192 GSLMatrix
Nm(nrows, ncols);
193 for(
size_t i = 0 ; i <
nrows ; i++) {
194 for(
size_t j = 0 ; j <
ncols ; j++) {
213 gsl_vector *gv)
const {
217 else if(
size(gv) != (
size_t) v.dim()) {
219 mess <<
"Size of NL vector (" << v.dim() <<
") not same as GSL vector ("
226 for(
int i = 0 ; i < v.dim() ; i++) {
243 gsl_matrix *gm)
const {
247 else if((
Rows(gm) != (
size_t) m.dim1()) &&
248 (
Columns(gm) != (
size_t) m.dim2())) {
250 mess <<
"Size of NL matrix (" << m.dim1() <<
"," << m.dim2()
251 <<
") not same as GSL matrix (" <<
Rows(gm) <<
"," <<
Columns(gm)
258 for(
int i = 0 ; i < m.dim1() ; i++) {
259 for(
int j = 0 ; j < m.dim2() ; j++) {
308 if(gsl_status != GSL_SUCCESS) {
309 string msg =
"GSL error occured: " + string(
gsl_strerror(gsl_status));
334 mess <<
"GSLError (" << gsl_errno <<
") -> " <<
reason;
GSLUtility Provides top level interface to the GNU GSL.
size_t Rows(const gsl_matrix *m) const
Returns number of rows in a GSL matrix.
void free(gsl_vector *v) const
Frees a GSL vector.
size_t size(const gsl_vector *v) const
Returns the size of a GSL vector.
GSLVector gslToGSL(const gsl_vector *v) const
Converts a GSL vector to a TNT-based vector.
void setIdentity(gsl_matrix *m) const
Initializes an existing GSL matrix to the identity matrix.
gsl_vector * GSLTogsl(const GSLVector &v, gsl_vector *gv=0) const
Converts TNT-based vector to GSL vector.
static GSLUtility * _instance
Singleton self-reference pointer.
static void handler(const char *reason, const char *file, int line, int gsl_errno)
Special GSL errror handler.
GSLUtility()
Contructs a GSLUtility object with an error handler.
void check(int gsl_status, const char *src=__FILE__, int line=__LINE__) const
Performs a check on GSL library function return status.
gsl_matrix * matrix(size_t n1, size_t n2, bool zero=false) const
Creates a GSL matrix.
static GSLUtility * getInstance()
Return a reference to the GSL (singleton) object.
size_t Columns(const gsl_matrix *m) const
Returns the number of coulumns in a GSL matrix.
gsl_vector * vector(size_t n, bool zero=false) const
Creates a GSL vector.
gsl_matrix * identity(size_t n1, size_t n2) const
Returns a GSL identity matrix of the specified size.
@ Programmer
This error is for when a programmer made an API call that was illegal.
This is free and unencumbered software released into the public domain.
Namespace for the standard library.