;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; 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")



#? *** interpolation

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

#? * (dummy_interpolation)
#? * (gsl_interp_accel_alloc)
#? * (gsl_interp_accel_find <a> <x_array> <size> <x>)
#? * (gsl_interp_accel_reset <a>)
#? * (gsl_interp_accel_free <a>)
#? * (gsl_interp_alloc <p> <n>)
#? * (gsl_interp_init <obj> <xa> <ya> <size>)
#? * (gsl_interp_name <interp>)
#? * (gsl_interp_min_size <interp>)
#? * (gsl_interp_eval_e <obj> <xa> <ya> <x> <a> <y>)
#? * (gsl_interp_eval <obj> <xa> <ya> <x> <a>)
#? * (gsl_interp_eval_deriv_e <obj> <xa> <ya> <x> <a> <d>)
#? * (gsl_interp_eval_deriv <obj> <xa> <ya> <x> <a>)
#? * (gsl_interp_eval_deriv2_e <obj> <xa> <ya> <x> <a> <d2>)
#? * (gsl_interp_eval_deriv2 <obj> <xa> <ya> <x> <a>)
#? * (gsl_interp_eval_integ_e <obj> <xa> <ya> <a> <b> <acc> <result>)
#? * (gsl_interp_eval_integ <obj> <xa> <ya> <a> <b> <acc>)
#? * (gsl_interp_free <interp>)
#? * (gsl_interp_bsearch <x_array> <x> <index_lo> <index_hi>)
#? * (gsl_spline_alloc <p> <n>)
#? * (gsl_spline_init <spline> <xa> <ya> <size>)
#? * (gsl_spline_eval_e <spline> <x> <a> <y>)
#? * (gsl_spline_eval <spline> <x> <a>)
#? * (gsl_spline_eval_deriv_e <spline> <x> <a> <y>)
#? * (gsl_spline_eval_deriv <spline> <x> <a>)
#? * (gsl_spline_eval_deriv2_e <spline> <x> <a> <y>)
#? * (gsl_spline_eval_deriv2 <spline> <x> <a>)
#? * (gsl_spline_eval_integ_e <spline> <a> <b> <acc> <y>)
#? * (gsl_spline_eval_integ <spline> <a> <b> <acc>)
#? * (gsl_spline_free <spline>)

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


;;;;***********************************************************************************************
;;;;         gsl_interp

(de gsl_interp_accel_alloc ( )
    (gptr #{ gsl_interp_accel_alloc( ) #} )          ;; gsl_interp_accel * -> gptr
)


(de gsl_interp_accel_find (    a  x_array  size  x )
    ((-gptr- "gsl_interp_accel *") a) 
    ((-gptr- "const double *") x_array) 
    ((-int-) size)                     ;; size_t -> int
    ((-double-) x) 
    (int #{ gsl_interp_accel_find(  $a ,$x_array ,$size ,$x) #} )                ;; size_t -> int
)


(de gsl_interp_accel_reset (    a )
    ((-gptr- "gsl_interp_accel *") a) 
    (int #{ gsl_interp_accel_reset (  $a) #} )
)


(de gsl_interp_accel_free (    a )
    ((-gptr- "gsl_interp_accel *") a) 
    #{ gsl_interp_accel_free(  $a) #} 
    ()
)


(de gsl_interp_alloc (    p  n )
    ((-gptr- "const gsl_interp_type *") p) 
    ((-int-) n)                     ;; size_t -> int
    (gptr #{ gsl_interp_alloc(  $p ,$n) #} )          ;; gsl_interp * -> gptr
)

     
(de gsl_interp_init (    obj  xa  ya  size )
    ((-gptr- "gsl_interp *") obj) 
    ((-gptr- "const double *") xa) 
    ((-gptr- "const double *") ya) 
    ((-int-) size)                     ;; size_t -> int
    (int #{ gsl_interp_init(  $obj ,$xa ,$ya ,$size) #} )
)


(de gsl_interp_name (    interp )
    ((-gptr- "const gsl_interp *") interp) 
    (gptr #{ gsl_interp_name(  $interp) #} )          ;; const char * -> gptr
)

(de gsl_interp_min_size (    interp )
    ((-gptr- "const gsl_interp *") interp) 
    (int #{ gsl_interp_min_size(  $interp) #} )          ;; unsigned  -> signed
)



(de gsl_interp_eval_e (    obj  xa  ya  x  a  y )
    ((-gptr- "const gsl_interp *") obj) 
    ((-gptr- "const double *") xa) 
    ((-gptr- "const double *") ya) 
    ((-double-) x) 
    ((-gptr- "gsl_interp_accel *") a) 
    ((-gptr- "double *") y) 
    (int #{ gsl_interp_eval_e(  $obj ,$xa ,$ya ,$x ,$a ,$y) #} )
)


(de gsl_interp_eval (    obj  xa  ya  x  a )
    ((-gptr- "const gsl_interp *") obj) 
    ((-gptr- "const double *") xa) 
    ((-gptr- "const double *") ya) 
    ((-double-) x) 
    ((-gptr- "gsl_interp_accel *") a) 
    (double #{ gsl_interp_eval(  $obj ,$xa ,$ya ,$x ,$a) #} )
)


(de gsl_interp_eval_deriv_e (    obj  xa  ya  x  a  d )
    ((-gptr- "const gsl_interp *") obj) 
    ((-gptr- "const double *") xa) 
    ((-gptr- "const double *") ya) 
    ((-double-) x) 
    ((-gptr- "gsl_interp_accel *") a) 
    ((-gptr- "double *") d) 
    (int #{ gsl_interp_eval_deriv_e(  $obj ,$xa ,$ya ,$x ,$a ,$d) #} )
)


(de gsl_interp_eval_deriv (    obj  xa  ya  x  a )
    ((-gptr- "const gsl_interp *") obj) 
    ((-gptr- "const double *") xa) 
    ((-gptr- "const double *") ya) 
    ((-double-) x) 
    ((-gptr- "gsl_interp_accel *") a) 
    (double #{ gsl_interp_eval_deriv(  $obj ,$xa ,$ya ,$x ,$a) #} )
)


(de gsl_interp_eval_deriv2_e (    obj  xa  ya  x  a  d2 )
    ((-gptr- "const gsl_interp *") obj) 
    ((-gptr- "const double *") xa) 
    ((-gptr- "const double *") ya) 
    ((-double-) x) 
    ((-gptr- "gsl_interp_accel *") a) 
    ((-gptr- "double *") d2) 
    (int #{ gsl_interp_eval_deriv2_e(  $obj ,$xa ,$ya ,$x ,$a ,$d2) #} )
)


(de gsl_interp_eval_deriv2 (    obj  xa  ya  x  a )
    ((-gptr- "const gsl_interp *") obj) 
    ((-gptr- "const double *") xa) 
    ((-gptr- "const double *") ya) 
    ((-double-) x) 
    ((-gptr- "gsl_interp_accel *") a) 
    (double #{ gsl_interp_eval_deriv2(  $obj ,$xa ,$ya ,$x ,$a) #} )
)


(de gsl_interp_eval_integ_e (    obj  xa  ya  a  b  acc  result )
    ((-gptr- "const gsl_interp *") obj) 
    ((-gptr- "const double *") xa) 
    ((-gptr- "const double *") ya) 
    ((-double-) a) 
    ((-double-) b) 
    ((-gptr- "gsl_interp_accel *") acc) 
    ((-gptr- "double *") result) 
    (int #{ gsl_interp_eval_integ_e(  $obj ,$xa ,$ya ,$a ,$b ,$acc ,$result) #} )
)


(de gsl_interp_eval_integ (    obj  xa  ya  a  b  acc )
    ((-gptr- "const gsl_interp *") obj) 
    ((-gptr- "const double *") xa) 
    ((-gptr- "const double *") ya) 
    ((-double-) a) 
    ((-double-) b) 
    ((-gptr- "gsl_interp_accel *") acc) 
    (double #{ gsl_interp_eval_integ(  $obj ,$xa ,$ya ,$a ,$b ,$acc) #} )
)


(de gsl_interp_free (    interp )
    ((-gptr- "gsl_interp *") interp) 
    #{ gsl_interp_free(  $interp) #} 
    ()
)


(de gsl_interp_bsearch (    x_array  x  index_lo  index_hi )
    ((-gptr- "const double *") x_array) 
    ((-double-) x) 
    ((-int-) index_lo)                     ;; size_t -> int
    ((-int-) index_hi)                     ;; size_t -> int
    (int #{ gsl_interp_bsearch(  $x_array ,$x ,$index_lo ,$index_hi) #} )                ;; size_t -> int
)


;;;;*************************************************************************************************
;;;;                gsl_spline


(de gsl_spline_alloc (    p  n )
    ((-gptr- "const gsl_interp_type *") p) 
    ((-int-) n)                     ;; size_t -> int
    (gptr #{ gsl_spline_alloc(  $p ,$n) #} )          ;; gsl_spline * -> gptr
)

     
(de gsl_spline_init (    spline  xa  ya  size )
    ((-gptr- "gsl_spline *") spline) 
    ((-gptr- "const double *") xa) 
    ((-gptr- "const double *") ya) 
    ((-int-) size)                     ;; size_t -> int
    (int #{ gsl_spline_init(  $spline ,$xa ,$ya ,$size) #} )
)



(de gsl_spline_eval_e (    spline  x  a  y )
    ((-gptr- "const gsl_spline *") spline) 
    ((-double-) x) 
    ((-gptr- "gsl_interp_accel *") a) 
    ((-gptr- "double *") y) 
    (int #{ gsl_spline_eval_e(  $spline ,$x ,$a ,$y) #} )
)


(de gsl_spline_eval (    spline  x  a )
    ((-gptr- "const gsl_spline *") spline) 
    ((-double-) x) 
    ((-gptr- "gsl_interp_accel *") a) 
    (double #{ gsl_spline_eval(  $spline ,$x ,$a) #} )
)


(de gsl_spline_eval_deriv_e (    spline  x  a  y )
    ((-gptr- "const gsl_spline *") spline) 
    ((-double-) x) 
    ((-gptr- "gsl_interp_accel *") a) 
    ((-gptr- "double *") y) 
    (int #{ gsl_spline_eval_deriv_e(  $spline ,$x ,$a ,$y) #} )
)


(de gsl_spline_eval_deriv (    spline  x  a )
    ((-gptr- "const gsl_spline *") spline) 
    ((-double-) x) 
    ((-gptr- "gsl_interp_accel *") a) 
    (double #{ gsl_spline_eval_deriv(  $spline ,$x ,$a) #} )
)


(de gsl_spline_eval_deriv2_e (    spline  x  a  y )
    ((-gptr- "const gsl_spline *") spline) 
    ((-double-) x) 
    ((-gptr- "gsl_interp_accel *") a) 
    ((-gptr- "double *") y) 
    (int #{ gsl_spline_eval_deriv2_e(  $spline ,$x ,$a ,$y) #} )
)


(de gsl_spline_eval_deriv2 (    spline  x  a )
    ((-gptr- "const gsl_spline *") spline) 
    ((-double-) x) 
    ((-gptr- "gsl_interp_accel *") a) 
    (double #{ gsl_spline_eval_deriv2(  $spline ,$x ,$a) #} )
)


(de gsl_spline_eval_integ_e (    spline  a  b  acc  y )
    ((-gptr- "const gsl_spline *") spline) 
    ((-double-) a) 
    ((-double-) b) 
    ((-gptr- "gsl_interp_accel *") acc) 
    ((-gptr- "double *") y) 
    (int #{ gsl_spline_eval_integ_e(  $spline ,$a ,$b ,$acc ,$y) #} )
)


(de gsl_spline_eval_integ (    spline  a  b  acc )
    ((-gptr- "const gsl_spline *") spline) 
    ((-double-) a) 
    ((-double-) b) 
    ((-gptr- "gsl_interp_accel *") acc) 
    (double #{ gsl_spline_eval_integ(  $spline ,$a ,$b ,$acc) #} )
)


(de gsl_spline_free (    spline )
    ((-gptr- "gsl_spline *") spline) 
    #{ gsl_spline_free(  $spline) #} 
    ()
)



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

(dhc-make ()
  dummy_interpolation
  gsl_interp_accel_alloc
  gsl_interp_accel_find
  gsl_interp_accel_reset
  gsl_interp_accel_free
  gsl_interp_alloc
  gsl_interp_init
  gsl_interp_name
  gsl_interp_min_size
  gsl_interp_eval_e
  gsl_interp_eval
  gsl_interp_eval_deriv_e
  gsl_interp_eval_deriv
  gsl_interp_eval_deriv2_e
  gsl_interp_eval_deriv2
  gsl_interp_eval_integ_e
  gsl_interp_eval_integ
  gsl_interp_free
  gsl_interp_bsearch
  gsl_spline_alloc
  gsl_spline_init
  gsl_spline_eval_e
  gsl_spline_eval
  gsl_spline_eval_deriv_e
  gsl_spline_eval_deriv
  gsl_spline_eval_deriv2_e
  gsl_spline_eval_deriv2
  gsl_spline_eval_integ_e
  gsl_spline_eval_integ
  gsl_spline_free
)
