Generated on Tue Dec 16 12:49:16 2008 for BIU-2.2.0 by doxygen 1.5.1

src/biu/qrng/gsl_errno.h

Go to the documentation of this file.
00001 /* err/gsl_errno.h
00002  * 
00003  * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, Brian Gough
00004  * 
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or (at
00008  * your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  */
00019 
00020 #ifndef __GSL_ERRNO_H__
00021 #define __GSL_ERRNO_H__
00022 
00023 #include <stdio.h>
00024 #include <errno.h>
00025 #include "biu/qrng/gsl_types.h"
00026 
00027 #undef __BEGIN_DECLS
00028 #undef __END_DECLS
00029 #ifdef __cplusplus
00030 # define __BEGIN_DECLS extern "C" {
00031 # define __END_DECLS }
00032 #else
00033 # define __BEGIN_DECLS /* empty */
00034 # define __END_DECLS /* empty */
00035 #endif
00036 
00037 __BEGIN_DECLS
00038 
00039 enum { 
00040   GSL_SUCCESS  = 0, 
00041   GSL_FAILURE  = -1,
00042   GSL_CONTINUE = -2,  /* iteration has not converged */
00043   GSL_EDOM     = 1,   /* input domain error, e.g sqrt(-1) */
00044   GSL_ERANGE   = 2,   /* output range error, e.g. exp(1e100) */
00045   GSL_EFAULT   = 3,   /* invalid pointer */
00046   GSL_EINVAL   = 4,   /* invalid argument supplied by user */
00047   GSL_EFAILED  = 5,   /* generic failure */
00048   GSL_EFACTOR  = 6,   /* factorization failed */
00049   GSL_ESANITY  = 7,   /* sanity check failed - shouldn't happen */
00050   GSL_ENOMEM   = 8,   /* malloc failed */
00051   GSL_EBADFUNC = 9,   /* problem with user-supplied function */
00052   GSL_ERUNAWAY = 10,  /* iterative process is out of control */
00053   GSL_EMAXITER = 11,  /* exceeded max number of iterations */
00054   GSL_EZERODIV = 12,  /* tried to divide by zero */
00055   GSL_EBADTOL  = 13,  /* user specified an invalid tolerance */
00056   GSL_ETOL     = 14,  /* failed to reach the specified tolerance */
00057   GSL_EUNDRFLW = 15,  /* underflow */
00058   GSL_EOVRFLW  = 16,  /* overflow  */
00059   GSL_ELOSS    = 17,  /* loss of accuracy */
00060   GSL_EROUND   = 18,  /* failed because of roundoff error */
00061   GSL_EBADLEN  = 19,  /* matrix, vector lengths are not conformant */
00062   GSL_ENOTSQR  = 20,  /* matrix not square */
00063   GSL_ESING    = 21,  /* apparent singularity detected */
00064   GSL_EDIVERGE = 22,  /* integral or series is divergent */
00065   GSL_EUNSUP   = 23,  /* requested feature is not supported by the hardware */
00066   GSL_EUNIMPL  = 24,  /* requested feature not (yet) implemented */
00067   GSL_ECACHE   = 25,  /* cache limit exceeded */
00068   GSL_ETABLE   = 26,  /* table limit exceeded */
00069   GSL_ENOPROG  = 27,  /* iteration is not making progress towards solution */
00070   GSL_ENOPROGJ = 28,  /* jacobian evaluations are not improving the solution */
00071   GSL_ETOLF    = 29,  /* cannot reach the specified tolerance in F */
00072   GSL_ETOLX    = 30,  /* cannot reach the specified tolerance in X */
00073   GSL_ETOLG    = 31,  /* cannot reach the specified tolerance in gradient */
00074   GSL_EOF      = 32   /* end of file */
00075 } ;
00076 
00077 void gsl_error (const char * reason, const char * file, int line,
00078                 int gsl_errno);
00079 
00080 void gsl_stream_printf (const char *label, const char *file,
00081                         int line, const char *reason);
00082 
00083 const char * gsl_strerror (const int gsl_errno);
00084 
00085 typedef void gsl_error_handler_t (const char * reason, const char * file,
00086                                   int line, int gsl_errno);
00087 
00088 typedef void gsl_stream_handler_t (const char * label, const char * file,
00089                                    int line, const char * reason);
00090 
00091 gsl_error_handler_t * 
00092 gsl_set_error_handler (gsl_error_handler_t * new_handler);
00093 
00094 gsl_error_handler_t *
00095 gsl_set_error_handler_off (void);
00096 
00097 gsl_stream_handler_t * 
00098 gsl_set_stream_handler (gsl_stream_handler_t * new_handler);
00099 
00100 FILE * gsl_set_stream (FILE * new_stream);
00101 
00102 /* GSL_ERROR: call the error handler, and return the error code */
00103 
00104 #define GSL_ERROR(reason, gsl_errno) \
00105        do { \
00106        gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
00107        return gsl_errno ; \
00108        } while (0)
00109 
00110 /* GSL_ERROR_VAL: call the error handler, and return the given value */
00111 
00112 #define GSL_ERROR_VAL(reason, gsl_errno, value) \
00113        do { \
00114        gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
00115        return value ; \
00116        } while (0)
00117 
00118 /* GSL_ERROR_VOID: call the error handler, and then return
00119    (for void functions which still need to generate an error) */
00120 
00121 #define GSL_ERROR_VOID(reason, gsl_errno) \
00122        do { \
00123        gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
00124        return ; \
00125        } while (0)
00126 
00127 /* GSL_ERROR_NULL suitable for out-of-memory conditions */
00128 
00129 #define GSL_ERROR_NULL(reason, gsl_errno) GSL_ERROR_VAL(reason, gsl_errno, 0)
00130 
00131 /* Sometimes you have several status results returned from
00132  * function calls and you want to combine them in some sensible
00133  * way. You cannot produce a "total" status condition, but you can
00134  * pick one from a set of conditions based on an implied hierarchy.
00135  *
00136  * In other words:
00137  *    you have: status_a, status_b, ...
00138  *    you want: status = (status_a if it is bad, or status_b if it is bad,...)
00139  *
00140  * In this example you consider status_a to be more important and
00141  * it is checked first, followed by the others in the order specified.
00142  *
00143  * Here are some dumb macros to do this.
00144  */
00145 #define GSL_ERROR_SELECT_2(a,b)       ((a) != GSL_SUCCESS ? (a) : ((b) != GSL_SUCCESS ? (b) : GSL_SUCCESS))
00146 #define GSL_ERROR_SELECT_3(a,b,c)     ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_2(b,c))
00147 #define GSL_ERROR_SELECT_4(a,b,c,d)   ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_3(b,c,d))
00148 #define GSL_ERROR_SELECT_5(a,b,c,d,e) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_4(b,c,d,e))
00149 
00150 #define GSL_STATUS_UPDATE(sp, s) do { if ((s) != GSL_SUCCESS) *(sp) = (s);} while(0)
00151 
00152 __END_DECLS
00153 
00154 #endif /* __GSL_ERRNO_H__ */