Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:00:54

0001 /* err/gsl_errno.h
0002  * 
0003  * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
0004  * 
0005  * This program is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation; either version 3 of the License, or (at
0008  * your option) any later version.
0009  * 
0010  * This program is distributed in the hope that it will be useful, but
0011  * WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * General Public License for more details.
0014  * 
0015  * You should have received a copy of the GNU General Public License
0016  * along with this program; if not, write to the Free Software
0017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #ifndef __GSL_ERRNO_H__
0021 #define __GSL_ERRNO_H__
0022 
0023 #include <stdio.h>
0024 #include <errno.h>
0025 #include <gsl/gsl_types.h>
0026 
0027 #undef __BEGIN_DECLS
0028 #undef __END_DECLS
0029 #ifdef __cplusplus
0030 # define __BEGIN_DECLS extern "C" {
0031 # define __END_DECLS }
0032 #else
0033 # define __BEGIN_DECLS /* empty */
0034 # define __END_DECLS /* empty */
0035 #endif
0036 
0037 __BEGIN_DECLS
0038 
0039 enum { 
0040   GSL_SUCCESS  = 0, 
0041   GSL_FAILURE  = -1,
0042   GSL_CONTINUE = -2,  /* iteration has not converged */
0043   GSL_EDOM     = 1,   /* input domain error, e.g sqrt(-1) */
0044   GSL_ERANGE   = 2,   /* output range error, e.g. exp(1e100) */
0045   GSL_EFAULT   = 3,   /* invalid pointer */
0046   GSL_EINVAL   = 4,   /* invalid argument supplied by user */
0047   GSL_EFAILED  = 5,   /* generic failure */
0048   GSL_EFACTOR  = 6,   /* factorization failed */
0049   GSL_ESANITY  = 7,   /* sanity check failed - shouldn't happen */
0050   GSL_ENOMEM   = 8,   /* malloc failed */
0051   GSL_EBADFUNC = 9,   /* problem with user-supplied function */
0052   GSL_ERUNAWAY = 10,  /* iterative process is out of control */
0053   GSL_EMAXITER = 11,  /* exceeded max number of iterations */
0054   GSL_EZERODIV = 12,  /* tried to divide by zero */
0055   GSL_EBADTOL  = 13,  /* user specified an invalid tolerance */
0056   GSL_ETOL     = 14,  /* failed to reach the specified tolerance */
0057   GSL_EUNDRFLW = 15,  /* underflow */
0058   GSL_EOVRFLW  = 16,  /* overflow  */
0059   GSL_ELOSS    = 17,  /* loss of accuracy */
0060   GSL_EROUND   = 18,  /* failed because of roundoff error */
0061   GSL_EBADLEN  = 19,  /* matrix, vector lengths are not conformant */
0062   GSL_ENOTSQR  = 20,  /* matrix not square */
0063   GSL_ESING    = 21,  /* apparent singularity detected */
0064   GSL_EDIVERGE = 22,  /* integral or series is divergent */
0065   GSL_EUNSUP   = 23,  /* requested feature is not supported by the hardware */
0066   GSL_EUNIMPL  = 24,  /* requested feature not (yet) implemented */
0067   GSL_ECACHE   = 25,  /* cache limit exceeded */
0068   GSL_ETABLE   = 26,  /* table limit exceeded */
0069   GSL_ENOPROG  = 27,  /* iteration is not making progress towards solution */
0070   GSL_ENOPROGJ = 28,  /* jacobian evaluations are not improving the solution */
0071   GSL_ETOLF    = 29,  /* cannot reach the specified tolerance in F */
0072   GSL_ETOLX    = 30,  /* cannot reach the specified tolerance in X */
0073   GSL_ETOLG    = 31,  /* cannot reach the specified tolerance in gradient */
0074   GSL_EOF      = 32   /* end of file */
0075 } ;
0076 
0077 void gsl_error (const char * reason, const char * file, int line,
0078                 int gsl_errno);
0079 
0080 void gsl_stream_printf (const char *label, const char *file,
0081                         int line, const char *reason);
0082 
0083 const char * gsl_strerror (const int gsl_errno);
0084 
0085 typedef void gsl_error_handler_t (const char * reason, const char * file,
0086                                   int line, int gsl_errno);
0087 
0088 typedef void gsl_stream_handler_t (const char * label, const char * file,
0089                                    int line, const char * reason);
0090 
0091 gsl_error_handler_t * 
0092 gsl_set_error_handler (gsl_error_handler_t * new_handler);
0093 
0094 gsl_error_handler_t *
0095 gsl_set_error_handler_off (void);
0096 
0097 gsl_stream_handler_t * 
0098 gsl_set_stream_handler (gsl_stream_handler_t * new_handler);
0099 
0100 FILE * gsl_set_stream (FILE * new_stream);
0101 
0102 /* GSL_ERROR: call the error handler, and return the error code */
0103 
0104 #define GSL_ERROR(reason, gsl_errno) \
0105        do { \
0106        gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
0107        return gsl_errno ; \
0108        } while (0)
0109 
0110 /* GSL_ERROR_VAL: call the error handler, and return the given value */
0111 
0112 #define GSL_ERROR_VAL(reason, gsl_errno, value) \
0113        do { \
0114        gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
0115        return value ; \
0116        } while (0)
0117 
0118 /* GSL_ERROR_VOID: call the error handler, and then return
0119    (for void functions which still need to generate an error) */
0120 
0121 #define GSL_ERROR_VOID(reason, gsl_errno) \
0122        do { \
0123        gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
0124        return ; \
0125        } while (0)
0126 
0127 /* GSL_ERROR_NULL suitable for out-of-memory conditions */
0128 
0129 #define GSL_ERROR_NULL(reason, gsl_errno) GSL_ERROR_VAL(reason, gsl_errno, 0)
0130 
0131 /* Sometimes you have several status results returned from
0132  * function calls and you want to combine them in some sensible
0133  * way. You cannot produce a "total" status condition, but you can
0134  * pick one from a set of conditions based on an implied hierarchy.
0135  *
0136  * In other words:
0137  *    you have: status_a, status_b, ...
0138  *    you want: status = (status_a if it is bad, or status_b if it is bad,...)
0139  *
0140  * In this example you consider status_a to be more important and
0141  * it is checked first, followed by the others in the order specified.
0142  *
0143  * Here are some dumb macros to do this.
0144  */
0145 #define GSL_ERROR_SELECT_2(a,b)       ((a) != GSL_SUCCESS ? (a) : ((b) != GSL_SUCCESS ? (b) : GSL_SUCCESS))
0146 #define GSL_ERROR_SELECT_3(a,b,c)     ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_2(b,c))
0147 #define GSL_ERROR_SELECT_4(a,b,c,d)   ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_3(b,c,d))
0148 #define GSL_ERROR_SELECT_5(a,b,c,d,e) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_4(b,c,d,e))
0149 
0150 #define GSL_STATUS_UPDATE(sp, s) do { if ((s) != GSL_SUCCESS) *(sp) = (s);} while(0)
0151 
0152 __END_DECLS
0153 
0154 #endif /* __GSL_ERRNO_H__ */