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



#? *** multiroots

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

#? * (dummy_multiroots)
#? * (gsl_multiroot_fdjacobian <fp> <x> <f> <epsrel> <jacobian>)
#? * (gsl_multiroot_fsolver_alloc <p> <n>)
#? * (gsl_multiroot_fsolver_free <s>)
#? * (gsl_multiroot_fsolver_set <s> <f> <x>)
#? * (gsl_multiroot_fsolver_iterate <s>)
#? * (gsl_multiroot_fsolver_name <s>)
#? * (gsl_multiroot_fsolver_root <s>)
#? * (gsl_multiroot_fdfsolver_alloc <p> <n>)
#? * (gsl_multiroot_fdfsolver_set <s> <fdf> <x>)
#? * (gsl_multiroot_fdfsolver_iterate <s>)
#? * (gsl_multiroot_fdfsolver_free <s>)
#? * (gsl_multiroot_fdfsolver_name <s>)
#? * (gsl_multiroot_fdfsolver_root <s>)
#? * (gsl_multiroot_test_delta <dx> <x> <epsabs> <epsrel>)
#? * (gsl_multiroot_test_residual <f> <epsabs>)

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


(de gsl_multiroot_fdjacobian (    fp  x  f  epsrel  jacobian )
    ((-gptr- "gsl_multiroot_function *") fp) 
    ((-gptr- "const gsl_vector *") x) 
    ((-gptr- "const gsl_vector *") f) 
    ((-double-) epsrel) 
    ((-gptr- "gsl_matrix *") jacobian) 
    (int #{ gsl_multiroot_fdjacobian (  $fp ,$x ,$f ,$epsrel ,$jacobian) #} )
)



(de gsl_multiroot_fsolver_alloc (    p  n )
    ((-gptr- "const gsl_multiroot_fsolver_type *") p) 
    ((-int-) n)                     ;; size_t -> int
    (gptr #{ gsl_multiroot_fsolver_alloc (  $p ,$n) #} )          ;; gsl_multiroot_fsolver * -> gptr
)
 

(de gsl_multiroot_fsolver_free (    s )
    ((-gptr- "gsl_multiroot_fsolver *") s) 
    #{ gsl_multiroot_fsolver_free (  $s) #} 
    ()
)


(de gsl_multiroot_fsolver_set (    s  f  x )
    ((-gptr- "gsl_multiroot_fsolver *") s) 
    ((-gptr- "gsl_multiroot_function *") f) 
    ((-gptr- "gsl_vector *") x) 
    (int #{ gsl_multiroot_fsolver_set (  $s ,$f ,$x) #} )
)


(de gsl_multiroot_fsolver_iterate (    s )
    ((-gptr- "gsl_multiroot_fsolver *") s) 
    (int #{ gsl_multiroot_fsolver_iterate (  $s) #} )
)


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

(de gsl_multiroot_fsolver_root (    s )
    ((-gptr- "const gsl_multiroot_fsolver *") s) 
    (gptr #{ gsl_multiroot_fsolver_root (  $s) #} )          ;; gsl_vector * -> gptr
)




(de gsl_multiroot_fdfsolver_alloc (    p  n )
    ((-gptr- "const gsl_multiroot_fdfsolver_type *") p) 
    ((-int-) n)                     ;; size_t -> int
    (gptr #{ gsl_multiroot_fdfsolver_alloc (  $p ,$n) #} )          ;; gsl_multiroot_fdfsolver * -> gptr
)


(de gsl_multiroot_fdfsolver_set (    s  fdf  x )
    ((-gptr- "gsl_multiroot_fdfsolver *") s) 
    ((-gptr- "gsl_multiroot_function_fdf *") fdf) 
    ((-gptr- "gsl_vector *") x) 
    (int #{ gsl_multiroot_fdfsolver_set (  $s ,$fdf ,$x) #} )
)


(de gsl_multiroot_fdfsolver_iterate (    s )
    ((-gptr- "gsl_multiroot_fdfsolver *") s) 
    (int #{ gsl_multiroot_fdfsolver_iterate (  $s) #} )
)


(de gsl_multiroot_fdfsolver_free (    s )
    ((-gptr- "gsl_multiroot_fdfsolver *") s) 
    #{ gsl_multiroot_fdfsolver_free (  $s) #} 
    ()
)


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

(de gsl_multiroot_fdfsolver_root (    s )
    ((-gptr- "const gsl_multiroot_fdfsolver *") s) 
    (gptr #{ gsl_multiroot_fdfsolver_root (  $s) #} )          ;; gsl_vector * -> gptr
)


(de gsl_multiroot_test_delta (    dx  x  epsabs  epsrel )
    ((-gptr- "const gsl_vector *") dx) 
    ((-gptr- "const gsl_vector *") x) 
    ((-double-) epsabs) 
    ((-double-) epsrel) 
    (int #{ gsl_multiroot_test_delta (  $dx ,$x ,$epsabs ,$epsrel) #} )
)


(de gsl_multiroot_test_residual (    f  epsabs )
    ((-gptr- "const gsl_vector *") f) 
    ((-double-) epsabs) 
    (int #{ gsl_multiroot_test_residual (  $f ,$epsabs) #} )
)

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

(dhc-make ()
  dummy_multiroots
  gsl_multiroot_fdjacobian
  gsl_multiroot_fsolver_alloc
  gsl_multiroot_fsolver_free
  gsl_multiroot_fsolver_set
  gsl_multiroot_fsolver_iterate
  gsl_multiroot_fsolver_name
  gsl_multiroot_fsolver_root
  gsl_multiroot_fdfsolver_alloc
  gsl_multiroot_fdfsolver_set
  gsl_multiroot_fdfsolver_iterate
  gsl_multiroot_fdfsolver_free
  gsl_multiroot_fdfsolver_name
  gsl_multiroot_fdfsolver_root
  gsl_multiroot_test_delta
  gsl_multiroot_test_residual
)
