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



#? *** multifit

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

#? * (dummy_multifit)
#? * (gsl_multifit_linear_alloc <n> <p>)
#? * (gsl_multifit_linear_free <work>)
#? * (gsl_multifit_linear <x> <y> <c> <cov> <chisq> <work>)
#? * (gsl_multifit_wlinear <x> <w> <y> <c> <cov> <chisq> <work>)
#? * (gsl_multifit_gradient <j> <f> <g>)
#? * (gsl_multifit_covar <j> <epsrel> <covar>)
#? * (gsl_multifit_fdjacobian <fp> <x> <f> <epsrel> <jacobian>)
#? * (gsl_multifit_fsolver_alloc <s> <n> <p>)
#? * (gsl_multifit_fsolver_free <s>)
#? * (gsl_multifit_fsolver_set <s> <f> <x>)
#? * (gsl_multifit_fsolver_iterate <s>)
#? * (gsl_multifit_fsolver_name <s>)
#? * (gsl_multifit_fsolver_position <s>)
#? * (gsl_multifit_fdfsolver_alloc <s> <n> <p>)
#? * (gsl_multifit_fdfsolver_set <s> <fdf> <x>)
#? * (gsl_multifit_fdfsolver_iterate <s>)
#? * (gsl_multifit_fdfsolver_free <s>)
#? * (gsl_multifit_fdfsolver_name <s>)
#? * (gsl_multifit_fdfsolver_position <s>)
#? * (gsl_multifit_test_delta <dx> <x> <epsabs> <epsrel>)
#? * (gsl_multifit_test_gradient <g> <epsabs>)

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


;;;;**********************************************************************************************
;;;;             gsl_multifit

(de gsl_multifit_linear_alloc (    n  p )
    ((-int-) n)                     ;; size_t -> int
    ((-int-) p)                     ;; size_t -> int
    (gptr #{ gsl_multifit_linear_alloc (  $n ,$p) #} )          ;; gsl_multifit_linear_workspace * -> gptr
)


(de gsl_multifit_linear_free (    work )
    ((-gptr- "gsl_multifit_linear_workspace *") work) 
    #{ gsl_multifit_linear_free (  $work) #} 
    ()
)


(de gsl_multifit_linear (    x  y  c  cov  chisq  work )
    ((-gptr- "const gsl_matrix *") x) 
    ((-gptr- "const gsl_vector *") y) 
    ((-gptr- "gsl_vector *") c) 
    ((-gptr- "gsl_matrix *") cov) 
    ((-gptr- "double *") chisq) 
    ((-gptr- "gsl_multifit_linear_workspace *") work) 
    (int #{ gsl_multifit_linear (  $x ,$y ,$c ,$cov ,$chisq ,$work) #} )
)


(de gsl_multifit_wlinear (    x  w  y  c  cov  chisq  work )
    ((-gptr- "const gsl_matrix *") x) 
    ((-gptr- "const gsl_vector *") w) 
    ((-gptr- "const gsl_vector *") y) 
    ((-gptr- "gsl_vector *") c) 
    ((-gptr- "gsl_matrix *") cov) 
    ((-gptr- "double *") chisq) 
    ((-gptr- "gsl_multifit_linear_workspace *") work) 
    (int #{ gsl_multifit_wlinear (  $x ,$w ,$y ,$c ,$cov ,$chisq ,$work) #} )
)


;;;;**********************************************************************************************
;;;;                    gsl_multifit_nlin

(de gsl_multifit_gradient (    j  f  g )
    ((-gptr- "const gsl_matrix *") j) 
    ((-gptr- "const gsl_vector *") f) 
    ((-gptr- "gsl_vector *") g) 
    (int #{ gsl_multifit_gradient (  $j ,$f ,$g) #} )
)


(de gsl_multifit_covar (    j  epsrel  covar )
    ((-gptr- "const gsl_matrix *") j) 
    ((-double-) epsrel) 
    ((-gptr- "gsl_matrix *") covar) 
    (int #{ gsl_multifit_covar (  $j ,$epsrel ,$covar) #} )
)






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


(de gsl_multifit_fsolver_alloc (    s  n  p )
    ((-gptr- "const gsl_multifit_fsolver_type *") s) 
    ((-int-) n)                     ;; size_t -> int
    ((-int-) p)                     ;; size_t -> int
    (gptr #{ gsl_multifit_fsolver_alloc (  $s ,$n ,$p) #} )          ;; gsl_multifit_fsolver * -> gptr
)


(de gsl_multifit_fsolver_free (    s )
    ((-gptr- "gsl_multifit_fsolver *") s) 
    #{ gsl_multifit_fsolver_free (  $s) #} 
    ()
)


(de gsl_multifit_fsolver_set (    s  f  x )
    ((-gptr- "gsl_multifit_fsolver *") s) 
    ((-gptr- "gsl_multifit_function *") f) 
    ((-gptr- "gsl_vector *") x) 
    (int #{ gsl_multifit_fsolver_set (  $s ,$f ,$x) #} )
)


(de gsl_multifit_fsolver_iterate (    s )
    ((-gptr- "gsl_multifit_fsolver *") s) 
    (int #{ gsl_multifit_fsolver_iterate (  $s) #} )
)


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

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



(de gsl_multifit_fdfsolver_alloc (    s  n  p )
    ((-gptr- "const gsl_multifit_fdfsolver_type *") s) 
    ((-int-) n)                     ;; size_t -> int
    ((-int-) p)                     ;; size_t -> int
    (gptr #{ gsl_multifit_fdfsolver_alloc (  $s ,$n ,$p) #} )          ;; gsl_multifit_fdfsolver * -> gptr
)


(de gsl_multifit_fdfsolver_set (    s  fdf  x )
    ((-gptr- "gsl_multifit_fdfsolver *") s) 
    ((-gptr- "gsl_multifit_function_fdf *") fdf) 
    ((-gptr- "gsl_vector *") x) 
    (int #{ gsl_multifit_fdfsolver_set (  $s ,$fdf ,$x) #} )
)


(de gsl_multifit_fdfsolver_iterate (    s )
    ((-gptr- "gsl_multifit_fdfsolver *") s) 
    (int #{ gsl_multifit_fdfsolver_iterate (  $s) #} )
)


(de gsl_multifit_fdfsolver_free (    s )
    ((-gptr- "gsl_multifit_fdfsolver *") s) 
    #{ gsl_multifit_fdfsolver_free (  $s) #} 
    ()
)


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

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


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


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

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

(dhc-make ()
  dummy_multifit
  gsl_multifit_linear_alloc
  gsl_multifit_linear_free
  gsl_multifit_linear
  gsl_multifit_wlinear
  gsl_multifit_gradient
  gsl_multifit_covar
;;  gsl_multifit_fdjacobian
  gsl_multifit_fsolver_alloc
  gsl_multifit_fsolver_free
  gsl_multifit_fsolver_set
  gsl_multifit_fsolver_iterate
  gsl_multifit_fsolver_name
  gsl_multifit_fsolver_position
  gsl_multifit_fdfsolver_alloc
  gsl_multifit_fdfsolver_set
  gsl_multifit_fdfsolver_iterate
  gsl_multifit_fdfsolver_free
  gsl_multifit_fdfsolver_name
  gsl_multifit_fdfsolver_position
  gsl_multifit_test_delta
  gsl_multifit_test_gradient
)
