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



#? *** min

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

#? * (dummy_min)
#? * (gsl_min_fminimizer_alloc <p>)
#? * (gsl_min_fminimizer_free <s>)
#? * (gsl_min_fminimizer_set <s> <f> <minimum> <x_lower> <x_upper>)
#? * (gsl_min_fminimizer_set_with_values <s> <f> <minimum> <f_minimum> <x_lower> <f_lower> <x_upper> <f_upper>)
#? * (gsl_min_fminimizer_iterate <s>)
#? * (gsl_min_fminimizer_name <s>)
#? * (gsl_min_fminimizer_minimum <s>)
#? * (gsl_min_fminimizer_x_lower <s>)
#? * (gsl_min_fminimizer_x_upper <s>)
#? * (gsl_min_test_interval <x_lower> <x_upper> <epsabs> <epsrel>)
#? * (gsl_min_find_bracket <f> <minimum> <f_minimum> <x_lower> <f_lower> <x_upper> <f_upper> <eval_max>)

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



(de gsl_min_fminimizer_alloc (    p )
    ((-gptr- "const gsl_min_fminimizer_type *") p) 
    (gptr #{ gsl_min_fminimizer_alloc (  $p)  #} )          ;; gsl_min_fminimizer * -> gptr
)

                                      
(de gsl_min_fminimizer_free (    s )
    ((-gptr- "gsl_min_fminimizer *") s) 
    #{ gsl_min_fminimizer_free (  $s) #} 
    ()
)


(de gsl_min_fminimizer_set (    s  f  minimum  x_lower  x_upper )
    ((-gptr- "gsl_min_fminimizer *") s) 
    ((-gptr- "gsl_function *") f) 
    ((-double-) minimum) 
    ((-double-) x_lower) 
    ((-double-) x_upper) 
    (int #{ gsl_min_fminimizer_set (  $s ,$f ,$minimum ,$x_lower ,$x_upper) #} )
)


(de gsl_min_fminimizer_set_with_values (    s  f  minimum  f_minimum  x_lower  f_lower  x_upper  f_upper )
    ((-gptr- "gsl_min_fminimizer *") s) 
    ((-gptr- "gsl_function *") f) 
    ((-double-) minimum) 
    ((-double-) f_minimum) 
    ((-double-) x_lower) 
    ((-double-) f_lower) 
    ((-double-) x_upper) 
    ((-double-) f_upper) 
    (int #{ gsl_min_fminimizer_set_with_values (  $s ,$f ,$minimum ,$f_minimum ,$x_lower ,$f_lower ,$x_upper ,$f_upper) #} )
)


(de gsl_min_fminimizer_iterate (    s )
    ((-gptr- "gsl_min_fminimizer *") s) 
    (int #{ gsl_min_fminimizer_iterate (  $s) #} )
)


(de gsl_min_fminimizer_name (    s )
    ((-gptr- "const gsl_min_fminimizer *") s) 
    (gptr #{ gsl_min_fminimizer_name (  $s) #} )          ;; const char * -> gptr
)

(de gsl_min_fminimizer_minimum (    s )
    ((-gptr- "const gsl_min_fminimizer *") s) 
    (double #{ gsl_min_fminimizer_minimum (  $s) #} )
)

(de gsl_min_fminimizer_x_lower (    s )
    ((-gptr- "const gsl_min_fminimizer *") s) 
    (double #{ gsl_min_fminimizer_x_lower (  $s) #} )
)

(de gsl_min_fminimizer_x_upper (    s )
    ((-gptr- "const gsl_min_fminimizer *") s) 
    (double #{ gsl_min_fminimizer_x_upper (  $s) #} )
)


(de gsl_min_test_interval (    x_lower  x_upper  epsabs  epsrel )
    ((-double-) x_lower) 
    ((-double-) x_upper) 
    ((-double-) epsabs) 
    ((-double-) epsrel) 
    (int #{ gsl_min_test_interval (  $x_lower ,$x_upper ,$epsabs ,$epsrel) #} )
)


(de gsl_min_find_bracket (     f   minimum  f_minimum   x_lower  f_lower   x_upper  f_upper  eval_max )
    ((-gptr- "gsl_function *") f) 
    ((-gptr- "double *") minimum) 
    ((-gptr- "double *") f_minimum) 
    ((-gptr- "double *") x_lower) 
    ((-gptr- "double *") f_lower) 
    ((-gptr- "double *") x_upper) 
    ((-gptr- "double *") f_upper) 
    ((-int-) eval_max)                     ;; size_t -> int
    (int #{ gsl_min_find_bracket(  $f ,$minimum ,$f_minimum ,$x_lower ,$f_lower ,$x_upper ,$f_upper ,$eval_max) #} )
)


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

(dhc-make ()
  dummy_min
  gsl_min_fminimizer_alloc
  gsl_min_fminimizer_free
  gsl_min_fminimizer_set
  gsl_min_fminimizer_set_with_values
  gsl_min_fminimizer_iterate
  gsl_min_fminimizer_name
  gsl_min_fminimizer_minimum
  gsl_min_fminimizer_x_lower
  gsl_min_fminimizer_x_upper
  gsl_min_test_interval
  gsl_min_find_bracket
)
