Blame err/gsl_errno.h

Packit 67cb25
/* err/gsl_errno.h
Packit 67cb25
 * 
Packit 67cb25
 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
Packit 67cb25
 * 
Packit 67cb25
 * This program is free software; you can redistribute it and/or modify
Packit 67cb25
 * it under the terms of the GNU General Public License as published by
Packit 67cb25
 * the Free Software Foundation; either version 3 of the License, or (at
Packit 67cb25
 * your option) any later version.
Packit 67cb25
 * 
Packit 67cb25
 * This program is distributed in the hope that it will be useful, but
Packit 67cb25
 * WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 67cb25
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 67cb25
 * General Public License for more details.
Packit 67cb25
 * 
Packit 67cb25
 * You should have received a copy of the GNU General Public License
Packit 67cb25
 * along with this program; if not, write to the Free Software
Packit 67cb25
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Packit 67cb25
 */
Packit 67cb25
Packit 67cb25
#ifndef __GSL_ERRNO_H__
Packit 67cb25
#define __GSL_ERRNO_H__
Packit 67cb25
Packit 67cb25
#include <stdio.h>
Packit 67cb25
#include <errno.h>
Packit 67cb25
#include <gsl/gsl_types.h>
Packit 67cb25
Packit 67cb25
#undef __BEGIN_DECLS
Packit 67cb25
#undef __END_DECLS
Packit 67cb25
#ifdef __cplusplus
Packit 67cb25
# define __BEGIN_DECLS extern "C" {
Packit 67cb25
# define __END_DECLS }
Packit 67cb25
#else
Packit 67cb25
# define __BEGIN_DECLS /* empty */
Packit 67cb25
# define __END_DECLS /* empty */
Packit 67cb25
#endif
Packit 67cb25
Packit 67cb25
__BEGIN_DECLS
Packit 67cb25
Packit 67cb25
enum { 
Packit 67cb25
  GSL_SUCCESS  = 0, 
Packit 67cb25
  GSL_FAILURE  = -1,
Packit 67cb25
  GSL_CONTINUE = -2,  /* iteration has not converged */
Packit 67cb25
  GSL_EDOM     = 1,   /* input domain error, e.g sqrt(-1) */
Packit 67cb25
  GSL_ERANGE   = 2,   /* output range error, e.g. exp(1e100) */
Packit 67cb25
  GSL_EFAULT   = 3,   /* invalid pointer */
Packit 67cb25
  GSL_EINVAL   = 4,   /* invalid argument supplied by user */
Packit 67cb25
  GSL_EFAILED  = 5,   /* generic failure */
Packit 67cb25
  GSL_EFACTOR  = 6,   /* factorization failed */
Packit 67cb25
  GSL_ESANITY  = 7,   /* sanity check failed - shouldn't happen */
Packit 67cb25
  GSL_ENOMEM   = 8,   /* malloc failed */
Packit 67cb25
  GSL_EBADFUNC = 9,   /* problem with user-supplied function */
Packit 67cb25
  GSL_ERUNAWAY = 10,  /* iterative process is out of control */
Packit 67cb25
  GSL_EMAXITER = 11,  /* exceeded max number of iterations */
Packit 67cb25
  GSL_EZERODIV = 12,  /* tried to divide by zero */
Packit 67cb25
  GSL_EBADTOL  = 13,  /* user specified an invalid tolerance */
Packit 67cb25
  GSL_ETOL     = 14,  /* failed to reach the specified tolerance */
Packit 67cb25
  GSL_EUNDRFLW = 15,  /* underflow */
Packit 67cb25
  GSL_EOVRFLW  = 16,  /* overflow  */
Packit 67cb25
  GSL_ELOSS    = 17,  /* loss of accuracy */
Packit 67cb25
  GSL_EROUND   = 18,  /* failed because of roundoff error */
Packit 67cb25
  GSL_EBADLEN  = 19,  /* matrix, vector lengths are not conformant */
Packit 67cb25
  GSL_ENOTSQR  = 20,  /* matrix not square */
Packit 67cb25
  GSL_ESING    = 21,  /* apparent singularity detected */
Packit 67cb25
  GSL_EDIVERGE = 22,  /* integral or series is divergent */
Packit 67cb25
  GSL_EUNSUP   = 23,  /* requested feature is not supported by the hardware */
Packit 67cb25
  GSL_EUNIMPL  = 24,  /* requested feature not (yet) implemented */
Packit 67cb25
  GSL_ECACHE   = 25,  /* cache limit exceeded */
Packit 67cb25
  GSL_ETABLE   = 26,  /* table limit exceeded */
Packit 67cb25
  GSL_ENOPROG  = 27,  /* iteration is not making progress towards solution */
Packit 67cb25
  GSL_ENOPROGJ = 28,  /* jacobian evaluations are not improving the solution */
Packit 67cb25
  GSL_ETOLF    = 29,  /* cannot reach the specified tolerance in F */
Packit 67cb25
  GSL_ETOLX    = 30,  /* cannot reach the specified tolerance in X */
Packit 67cb25
  GSL_ETOLG    = 31,  /* cannot reach the specified tolerance in gradient */
Packit 67cb25
  GSL_EOF      = 32   /* end of file */
Packit 67cb25
} ;
Packit 67cb25
Packit 67cb25
void gsl_error (const char * reason, const char * file, int line,
Packit 67cb25
                int gsl_errno);
Packit 67cb25
Packit 67cb25
void gsl_stream_printf (const char *label, const char *file,
Packit 67cb25
                        int line, const char *reason);
Packit 67cb25
Packit 67cb25
const char * gsl_strerror (const int gsl_errno);
Packit 67cb25
Packit 67cb25
typedef void gsl_error_handler_t (const char * reason, const char * file,
Packit 67cb25
                                  int line, int gsl_errno);
Packit 67cb25
Packit 67cb25
typedef void gsl_stream_handler_t (const char * label, const char * file,
Packit 67cb25
                                   int line, const char * reason);
Packit 67cb25
Packit 67cb25
gsl_error_handler_t * 
Packit 67cb25
gsl_set_error_handler (gsl_error_handler_t * new_handler);
Packit 67cb25
Packit 67cb25
gsl_error_handler_t *
Packit 67cb25
gsl_set_error_handler_off (void);
Packit 67cb25
Packit 67cb25
gsl_stream_handler_t * 
Packit 67cb25
gsl_set_stream_handler (gsl_stream_handler_t * new_handler);
Packit 67cb25
Packit 67cb25
FILE * gsl_set_stream (FILE * new_stream);
Packit 67cb25
Packit 67cb25
/* GSL_ERROR: call the error handler, and return the error code */
Packit 67cb25
Packit 67cb25
#define GSL_ERROR(reason, gsl_errno) \
Packit 67cb25
       do { \
Packit 67cb25
       gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
Packit 67cb25
       return gsl_errno ; \
Packit 67cb25
       } while (0)
Packit 67cb25
Packit 67cb25
/* GSL_ERROR_VAL: call the error handler, and return the given value */
Packit 67cb25
Packit 67cb25
#define GSL_ERROR_VAL(reason, gsl_errno, value) \
Packit 67cb25
       do { \
Packit 67cb25
       gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
Packit 67cb25
       return value ; \
Packit 67cb25
       } while (0)
Packit 67cb25
Packit 67cb25
/* GSL_ERROR_VOID: call the error handler, and then return
Packit 67cb25
   (for void functions which still need to generate an error) */
Packit 67cb25
Packit 67cb25
#define GSL_ERROR_VOID(reason, gsl_errno) \
Packit 67cb25
       do { \
Packit 67cb25
       gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
Packit 67cb25
       return ; \
Packit 67cb25
       } while (0)
Packit 67cb25
Packit 67cb25
/* GSL_ERROR_NULL suitable for out-of-memory conditions */
Packit 67cb25
Packit 67cb25
#define GSL_ERROR_NULL(reason, gsl_errno) GSL_ERROR_VAL(reason, gsl_errno, 0)
Packit 67cb25
Packit 67cb25
/* Sometimes you have several status results returned from
Packit 67cb25
 * function calls and you want to combine them in some sensible
Packit 67cb25
 * way. You cannot produce a "total" status condition, but you can
Packit 67cb25
 * pick one from a set of conditions based on an implied hierarchy.
Packit 67cb25
 *
Packit 67cb25
 * In other words:
Packit 67cb25
 *    you have: status_a, status_b, ...
Packit 67cb25
 *    you want: status = (status_a if it is bad, or status_b if it is bad,...)
Packit 67cb25
 *
Packit 67cb25
 * In this example you consider status_a to be more important and
Packit 67cb25
 * it is checked first, followed by the others in the order specified.
Packit 67cb25
 *
Packit 67cb25
 * Here are some dumb macros to do this.
Packit 67cb25
 */
Packit 67cb25
#define GSL_ERROR_SELECT_2(a,b)       ((a) != GSL_SUCCESS ? (a) : ((b) != GSL_SUCCESS ? (b) : GSL_SUCCESS))
Packit 67cb25
#define GSL_ERROR_SELECT_3(a,b,c)     ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_2(b,c))
Packit 67cb25
#define GSL_ERROR_SELECT_4(a,b,c,d)   ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_3(b,c,d))
Packit 67cb25
#define GSL_ERROR_SELECT_5(a,b,c,d,e) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_4(b,c,d,e))
Packit 67cb25
Packit 67cb25
#define GSL_STATUS_UPDATE(sp, s) do { if ((s) != GSL_SUCCESS) *(sp) = (s);} while(0)
Packit 67cb25
Packit 67cb25
__END_DECLS
Packit 67cb25
Packit 67cb25
#endif /* __GSL_ERRNO_H__ */