;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; LUSH Lisp Universal Shell
;;;   Copyright (C) 2002 Leon Bottou, Yann Le Cun, AT&T Corp, NECI.
;;; Includes parts of TL3:
;;;   Copyright (C) 1987-1999 Leon Bottou and Neuristique.
;;; Includes selected parts of SN3.2:
;;;   Copyright (C) 1991-2001 AT&T Corp.
;;;
;;; Includes information derived from the GSL (Gnu Scientific Library)
;;;   header files which are copyrighted and distributed under the GPL
;;;   by their respective authors.
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(libload "gsl/gsl-config")



#? *** aux_macro_func

;; dummy function that adds GSL C header files in C file
(eval `(de dummy_aux_macro_func () ,gsl-cpheader-cmd ()))

#? * (dummy_aux_macro_func)
#? * (gsl_error <reason> <gsl_errno>)
#? * (gsl_error_val <reason> <gsl_errno> <value>)
#? * (gsl_error_null <reason> <gsl_errno>)
#? * (gsl_warning <warning> <gsl_errno>)
#? * (gsl_error_select_2 <a> <b>)
#? * (gsl_error_select_3 <a> <b> <c>)
#? * (gsl_error_select_4 <a> <b> <c> <d>)
#? * (gsl_error_select_5 <a> <b> <c> <d> <e>)
#? * (gsl_status_update <sp> <s>)
#? * (gsl_message <message> <mask>)
#? * (gsl_vector_real <z> <i>)
#? * (gsl_vector_imag <z> <i>)
#? * (gsl_vector_complex <zv> <i>)
#? * (gsl_complex_at <zv> <i>)
#? * (gsl_complex_float_at <zv> <i>)
#? * (gsl_complex_long_double_at <zv> <i>)
#? * (gsl_is_odd <n>)
#? * (gsl_is_even <n>)
#? * (gsl_sign <x>)
#? * (gsl_is_real <x>)
#? * (gsl_max <a> <b>)
#? * (gsl_min <a> <b>)
#? * (gsl_max_int <a> <b>)
#? * (gsl_min_int <a> <b>)
#? * (gsl_max_dbl <a> <b>)
#? * (gsl_min_dbl <a> <b>)
#? * (gsl_max_ldbl <a> <b>)
#? * (gsl_min_ldbl <a> <b>)
#? * (gsl_fn_eval <f> <x>)
#? * (gsl_fn_fdf_eval_f <fdf> <x>)
#? * (gsl_fn_fdf_eval_df <fdf> <x>)
#? * (gsl_fn_fdf_eval_f_df <fdf> <x> <y> <dy>)
#? * (gsl_fn_vec_eval <f> <x> <y>)
#? * (gsl_multifit_fn_eval <f> <x> <y>)
#? * (gsl_multifit_fn_eval_f <f> <x> <y>)
#? * (gsl_multifit_fn_eval_df <f> <x> <dy>)
#? * (gsl_multifit_fn_eval_f_df <f> <x> <y> <dy>)
#? * (gsl_multimin_fn_eval <f> <x>)
#? * (gsl_multimin_fn_eval_f <f> <x>)
#? * (gsl_multimin_fn_eval_df <f> <x> <g>)
#? * (gsl_multimin_fn_eval_f_df <f> <x> <y> <g>)
#? * (gsl_multiroot_fn_eval <f> <x> <y>)
#? * (gsl_multiroot_fn_eval_f <f> <x> <y>)
#? * (gsl_multiroot_fn_eval_df <f> <x> <dy>)
#? * (gsl_multiroot_fn_eval_f_df <f> <x> <y> <dy>)
#? * (gsl_odeiv_fn_eval <s> <p> <y> <f>)
#? * (gsl_odeiv_ja_eval <s> <p> <y> <dfdy> <dfdt>)
#? * (gsl_sf_result_set <r> <v> <e>)
#? * (gsl_complex_p <zp>)
#? * (gsl_complex_p_real <zp>)
#? * (gsl_complex_p_imag <zp>)
#? * (gsl_complex_eq <z1> <z2>)
#? * (gsl_set_complex_packed <zp> <n> <x> <y>)
#? * (gsl_mode_prec <mt>)
#? * (gsl_monte_fn_eval <f> <x>)

;; ********************************************************



;;;;*********************************************************
;;;;         err/gsl_errno.h

(de GSL_ERROR ( reason gsl_errno)  
    ((-gptr- "const char *") reason)
    ((-int-) gsl_errno)
    #{ GSL_ERROR($reason, $gsl_errno)  #}
    ())

(de GSL_ERROR_VAL (reason  gsl_errno  value) 
    ((-gptr- "const char *") reason)
    ((-int-) gsl_errno  value)
    #{ GSL_ERROR_VAL($reason, $gsl_errno, $value) #}
    ())

(de GSL_ERROR_NULL (reason  gsl_errno) 
    ((-gptr- "const char *") reason)
    ((-int-) gsl_errno)
    #{ GSL_ERROR_NULL($reason, $gsl_errno) #}
    ())



(de GSL_WARNING (warning  gsl_errno) 
    ((-gptr- "const char *") warning)
    ((-int-) gsl_errno)
    #{ GSL_WARNING($warning, $gsl_errno) #}
    ())

(de GSL_ERROR_SELECT_2 (a  b)      
    ((-int-)  a  b)
    (int #{ GSL_ERROR_SELECT_2($a,$b)      #}))


(de GSL_ERROR_SELECT_3 (a  b  c)    
    ((-int-)  a  b  c)
    (int #{ GSL_ERROR_SELECT_3($a,$b,$c)    #}))


(de GSL_ERROR_SELECT_4 (a  b  c  d)  
    ((-int-)  a  b  c  d)
    (int #{ GSL_ERROR_SELECT_4($a,$b,$c,$d)  #}))


(de GSL_ERROR_SELECT_5 (a  b  c  d  e)
    ((-int-)  a  b  c  d  e)
    (int #{ GSL_ERROR_SELECT_5($a,$b,$c,$d,$e) #} ))


(de GSL_STATUS_UPDATE (sp  s) 
    ((-gptr- "int *") sp)
    ((-int-) s)
    #{ GSL_STATUS_UPDATE($sp, $s) #}
    ())


;;;;***********************************************************
;;;;        err/gsl_message.h

(de GSL_MESSAGE (message  mask)
    ((-gptr- "const char *") message)
    ((-int-) mask)
    #{ GSL_MESSAGE($message, $mask)#}
    ())

 

;;;;**************************************************************
;;;;      gsl_vector_complex.h

(de GSL_VECTOR_REAL (z  i)  
    ((-gptr- "gsl_vector_complex *") z)
    ((-int-) i)
    (double #{ GSL_VECTOR_REAL($z, $i)  #}))


(de GSL_VECTOR_IMAG (z  i)  
    ((-gptr- "gsl_vector_complex *") z)
    ((-int-) i)
    (double #{ GSL_VECTOR_IMAG($z, $i)  #}))


;;;; in the gsl, the GSL_VECTOR_COMPLEX macro has ambiguity
;;;; it can return either a pointer to complex, or a complex itself
;;;; when compiled under different conditions. 
;;;; (see: vector/gsl_vector_complex.h)
;;;; here we adopt the one returning a pointer
(de GSL_VECTOR_COMPLEX (zv  i) 
    ((-gptr- "gsl_vector_complex *") zv)
    ((-int-) i)
    (gptr  #{ GSL_COMPLEX_AT($zv, $i) #}))


(de GSL_COMPLEX_AT (zv  i) 
    ((-gptr- "gsl_vector_complex *") zv)
    ((-int-) i)
    (gptr #{ GSL_COMPLEX_AT($zv,$i) #}))


(de GSL_COMPLEX_FLOAT_AT (zv  i) 
    ((-gptr- "gsl_vector_complex_float *") zv)
    ((-int-) i)
    (gptr #{ GSL_COMPLEX_FLOAT_AT($zv,$i) #}))


(de GSL_COMPLEX_LONG_DOUBLE_AT (zv  i) 
    ((-gptr- "gsl_vector_complex_long_double *") zv)
    ((-int-) i)
    (gptr #{ GSL_COMPLEX_LONG_DOUBLE_AT($zv,$i) #} ))


;;;;*******************************************************************
;;;;   gsl_match.h


(de GSL_IS_ODD (n)  
    ((-int-) n)
    (int #{ GSL_IS_ODD($n)  #} ))

(de GSL_IS_EVEN (n) 
    ((-int-) n)
    (int #{ GSL_IS_EVEN($n) #} ))


(de GSL_SIGN (x)    
    ((-double-) x)
    (int #{ GSL_SIGN($x)    #}))


(de GSL_IS_REAL (x) 
    ((-double-) x)
    #{ GSL_IS_REAL($x) #}
    ())

(de GSL_MAX (a  b) 
    ((-double-) a b)
    (double #{ GSL_MAX($a,$b) #}))


(de GSL_MIN (a  b) 
    ((-double-) a b)
    (double #{ GSL_MIN($a,$b) #}))


(de GSL_MAX_INT (a  b)   
    ((-int-) a b)
    (int #{ GSL_MAX_INT($a,$b)   #}))


(de GSL_MIN_INT (a  b)   
    ((-int-) a  b)
    (int #{ GSL_MIN_INT($a,$b)   #}))


(de GSL_MAX_DBL (a  b)   
    ((-double-) a b)
    (double #{ GSL_MAX_DBL($a,$b)   #}))


(de GSL_MIN_DBL (a  b)   
    ((-double-) a b)
    (double #{ GSL_MIN_DBL($a,$b)   #}))


(de GSL_MAX_LDBL (a  b)  
    ((-double-) a  b)
    (double #{ GSL_MAX_LDBL($a,$b)  #}))


(de GSL_MIN_LDBL (a  b)  
    ((-double-) a b)
    (double #{ GSL_MIN_LDBL($a,$b)  #}))



(de GSL_FN_EVAL (f  x) 
    ((-gptr- "gsl_function *") f)
    ((-double-) x)
    (double #{ GSL_FN_EVAL($f,$x) #}))



(de GSL_FN_FDF_EVAL_F (fdf  x) 
    ((-gptr- "gsl_function_fdf *") fdf)
    ((-double-) x)
    (double #{ GSL_FN_FDF_EVAL_F($fdf,$x) #}))


(de GSL_FN_FDF_EVAL_DF (fdf  x) 
    ((-gptr- "gsl_function_fdf *") fdf)
    ((-double-) x)
    (double #{ GSL_FN_FDF_EVAL_DF($fdf,$x) #}))


(de GSL_FN_FDF_EVAL_F_DF (fdf  x  y  dy) 
    ((-gptr- "gsl_function_fdf *") fdf)
    ((-double-) x)
    ((-gptr- "double *") y  dy)    
    #{ GSL_FN_FDF_EVAL_F_DF($fdf, $x, $y, $dy); #}
    ())


(de GSL_FN_VEC_EVAL (f  x  y) 
    ((-gptr- "gsl_function_vec *") f)
    ((-double-) x)
    ((-gptr- "double *") y)
    (int #{ GSL_FN_VEC_EVAL($f,$x,$y) #} ))





;;;;*****************************************************************
;;;;      multifit_nlin/gsl_multifit_nlin.h



(de GSL_MULTIFIT_FN_EVAL (f  x  y) 
    ((-gptr- "gsl_multifit_function *") f)
    ((-gptr- "const gsl_vector *") x)
    ((-gptr- "gsl_vector *") y)
    (int #{ GSL_MULTIFIT_FN_EVAL($f,$x,$y) #}))


(de GSL_MULTIFIT_FN_EVAL_F (f  x  y) 
    ((-gptr- "gsl_multifit_function_fdf *") f)
    ((-gptr- "const gsl_vector *") x)
    ((-gptr- "gsl_vector *") y)
    (int #{ GSL_MULTIFIT_FN_EVAL_F($f,$x,$y) #}))


(de GSL_MULTIFIT_FN_EVAL_DF (f  x  dy) 
    ((-gptr- "gsl_multifit_function_fdf *") f)
    ((-gptr- "const gsl_vector *") x)
    ((-gptr- "gsl_matrix *") dy)
    (int #{ GSL_MULTIFIT_FN_EVAL_DF($f,$x,$dy) #}))


(de GSL_MULTIFIT_FN_EVAL_F_DF (f  x  y  dy) 
    ((-gptr- "gsl_multifit_function_fdf *") f)
    ((-gptr- "const gsl_vector *") x)
    ((-gptr- "gsl_vector *") y)
    ((-gptr- "gsl_matrix *") dy)
    (int #{ GSL_MULTIFIT_FN_EVAL_F_DF($f,$x,$y,$dy) #}))



;;;;***************************************************************
;;;;      multimin/gsl_multimin.h


(de GSL_MULTIMIN_FN_EVAL (f  x) 
    ((-gptr- "gsl_multimin_function *") f)
    ((-gptr- "const gsl_vector *") x)
    (double #{ GSL_MULTIMIN_FN_EVAL($f,$x) #}))


(de GSL_MULTIMIN_FN_EVAL_F (f  x) 
    ((-gptr- "gsl_multimin_function_fdf *") f)
    ((-gptr- "const gsl_vector *") x)
    (double #{ GSL_MULTIMIN_FN_EVAL_F($f,$x) #}))


(de GSL_MULTIMIN_FN_EVAL_DF (f  x  g) 
    ((-gptr- "gsl_multimin_function_fdf *") f)
    ((-gptr- "const gsl_vector *") x)
    ((-gptr- "gsl_vector *") g)
    #{ GSL_MULTIMIN_FN_EVAL_DF($f,$x,$g); #}
    ())

(de GSL_MULTIMIN_FN_EVAL_F_DF (f  x  y  g) 
    ((-gptr- "gsl_multimin_function_fdf *") f)
    ((-gptr- "const gsl_vector *") x)
    ((-gptr- "double *") y)
    ((-gptr- "gsl_vector *") g)
    #{ GSL_MULTIMIN_FN_EVAL_F_DF($f,$x,$y,$g); #}
    ())


;;;;****************************************************************
;;;;     multiroots/gsl_multiroots.h

(de GSL_MULTIROOT_FN_EVAL (f  x  y) 
    ((-gptr- "gsl_multiroot_function *") f)
    ((-gptr- "const gsl_vector *") x)
    ((-gptr- "gsl_vector *") y)
    (int #{ GSL_MULTIROOT_FN_EVAL($f,$x,$y) #}))


(de GSL_MULTIROOT_FN_EVAL_F (f  x  y) 
    ((-gptr- "gsl_multiroot_function_fdf *") f)
    ((-gptr- "const gsl_vector *") x)
    ((-gptr- "gsl_vector *") y)
    (int #{ GSL_MULTIROOT_FN_EVAL_F($f,$x,$y) #}))


(de GSL_MULTIROOT_FN_EVAL_DF (f  x  dy) 
    ((-gptr- "gsl_multiroot_function_fdf *") f)
    ((-gptr- "const gsl_vector *") x)
    ((-gptr- "gsl_matrix *") dy)
    (int #{ GSL_MULTIROOT_FN_EVAL_DF($f,$x,$dy) #}))


(de GSL_MULTIROOT_FN_EVAL_F_DF (f  x  y  dy) 
    ((-gptr- "gsl_multiroot_function_fdf *") f)
    ((-gptr- "const gsl_vector *") x)
    ((-gptr- "gsl_vector *") y)
    ((-gptr- "gsl_matrix *") dy)
    (int #{ GSL_MULTIROOT_FN_EVAL_F_DF($f,$x,$y,$dy) #}))




;;;;****************************************************************
;;;;     ode-initval/gsl_odeiv.h

(de GSL_ODEIV_FN_EVAL (s p y f)  
    ((-gptr- "gsl_odeiv_system *") s)
    ((-double-) p)
    ((-gptr- "const double *") y)
    ((-gptr- "double *") f)
    (int #{ GSL_ODEIV_FN_EVAL($s,$p,$y,$f)  #}))


(de GSL_ODEIV_JA_EVAL (s p y  dfdy  dfdt) 
    ((-gptr- "gsl_odeiv_system *") s)
    ((-double-) p)
    ((-gptr- "const double *") y)
    ((-gptr- "double *") dfdy)
    ((-gptr- "double *") dfdt)
    #{ GSL_ODEIV_JA_EVAL($s,$p,$y,$dfdy,$dfdt) #}
    ())



;;;;***************************************************************
;;;;    specfunc/gsl_sf_result.h

(de GSL_SF_RESULT_SET (r  v  e) 
    ((-gptr- "gsl_sf_result *") r)
    ((-double- ) v  e)
    #{ GSL_SF_RESULT_SET($r,$v,$e) #}
    ())



;;;;***************************************************************
;;;;    complex/gsl_complex.h

(de GSL_COMPLEX_P (zp) 
    ((-gptr- "gsl_complex *") zp)
    (gptr #{ GSL_COMPLEX_P($zp) #}))


(de GSL_COMPLEX_P_REAL (zp)  
    ((-gptr- "gsl_complex *") zp)
    (double #{ GSL_COMPLEX_P_REAL($zp)  #}))


(de GSL_COMPLEX_P_IMAG (zp)  
    ((-gptr- "gsl_complex *") zp)
    (double #{ GSL_COMPLEX_P_IMAG($zp)  #}))


;; pass in pointer instead of structure
(de GSL_COMPLEX_EQ (z1 z2) 
    ((-gptr- "gsl_complex *") z1 z2)
    (int #{ GSL_COMPLEX_EQ(*$z1,*$z2) #}))



(de GSL_SET_COMPLEX_PACKED (zp n x y) 
    ((-gptr- "double *") zp)
    ((-int-) n)
    ((-double-) x y)
    #{ GSL_SET_COMPLEX_PACKED($zp,$n,$x,$y) #}
    ())


;;;;****************************************************************
;;;;    gsl_mode.h

(de GSL_MODE_PREC (mt) 
    ((-int-) mt)
    (int #{ GSL_MODE_PREC((unsigned int)$mt) #}))


;;;;***************************************************************
;;;;    monte/gsl_monte.h

(de GSL_MONTE_FN_EVAL (f  x) 
    ((-gptr- "gsl_monte_function *") f)
    ((-gptr- "double *") x)
    (double #{ GSL_MONTE_FN_EVAL($f,$x) #}))

;; ********************************************************

(dhc-make ()
  dummy_aux_macro_func
  gsl_error
  gsl_error_val
  gsl_error_null
  gsl_warning
  gsl_error_select_2
  gsl_error_select_3
  gsl_error_select_4
  gsl_error_select_5
  gsl_status_update
  gsl_message
  gsl_vector_real
  gsl_vector_imag
  gsl_vector_complex
  gsl_complex_at
  gsl_complex_float_at
  gsl_complex_long_double_at
  gsl_is_odd
  gsl_is_even
  gsl_sign
  gsl_is_real
  gsl_max
  gsl_min
  gsl_max_int
  gsl_min_int
  gsl_max_dbl
  gsl_min_dbl
  gsl_max_ldbl
  gsl_min_ldbl
  gsl_fn_eval
  gsl_fn_fdf_eval_f
  gsl_fn_fdf_eval_df
  gsl_fn_fdf_eval_f_df
  gsl_fn_vec_eval
  gsl_multifit_fn_eval
  gsl_multifit_fn_eval_f
  gsl_multifit_fn_eval_df
  gsl_multifit_fn_eval_f_df
  gsl_multimin_fn_eval
  gsl_multimin_fn_eval_f
  gsl_multimin_fn_eval_df
  gsl_multimin_fn_eval_f_df
  gsl_multiroot_fn_eval
  gsl_multiroot_fn_eval_f
  gsl_multiroot_fn_eval_df
  gsl_multiroot_fn_eval_f_df
  gsl_odeiv_fn_eval
  gsl_odeiv_ja_eval
  gsl_sf_result_set
  gsl_complex_p
  gsl_complex_p_real
  gsl_complex_p_imag
  gsl_complex_eq
  gsl_set_complex_packed
  gsl_mode_prec
  gsl_monte_fn_eval
)
