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



#? *** fit

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

#? * (dummy_fit)
#? * (gsl_fit_linear <x> <xstride> <y> <ystride> <n> <c0> <c1> <cov00> <cov01> <cov11> <sumsq>)
#? * (gsl_fit_wlinear <x> <xstride> <w> <wstride> <y> <ystride> <n> <c0> <c1> <cov00> <cov01> <cov11> <chisq>)
#? * (gsl_fit_linear_est <x> <c0> <c1> <c00> <c01> <c11> <y> <y_err>)
#? * (gsl_fit_mul <x> <xstride> <y> <ystride> <n> <c1> <cov11> <sumsq>)
#? * (gsl_fit_wmul <x> <xstride> <w> <wstride> <y> <ystride> <n> <c1> <cov11> <sumsq>)
#? * (gsl_fit_mul_est <x> <c1> <c11> <y> <y_err>)
#? * (gsl_fit_poly <x> <w> <y> <n> <c> <m> <chisq>)
#? * (gsl_fit_fns <a> <w> <y> <n> <c> <m> <chisq>)
#? * (gsl_fit_linear_nd <m> <y> <w>)

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


(de gsl_fit_linear (    x  xstride  y  ystride  n  c0  c1  cov00  cov01  cov11  sumsq )
    ((-gptr- "const double *") x) 
    ((-int-) xstride)                     ;; size_t -> int
    ((-gptr- "const double *") y) 
    ((-int-) ystride)                     ;; size_t -> int
    ((-int-) n)                     ;; size_t -> int
    ((-gptr- "double *") c0) 
    ((-gptr- "double *") c1) 
    ((-gptr- "double *") cov00) 
    ((-gptr- "double *") cov01) 
    ((-gptr- "double *") cov11) 
    ((-gptr- "double *") sumsq) 
    (int #{ gsl_fit_linear (  $x ,$xstride ,$y ,$ystride ,$n ,$c0 ,$c1 ,$cov00 ,$cov01 ,$cov11 ,$sumsq) #} )
)



(de gsl_fit_wlinear (    x  xstride  w  wstride  y  ystride  n  c0  c1  cov00  cov01  cov11  chisq )
    ((-gptr- "const double *") x) 
    ((-int-) xstride)                     ;; size_t -> int
    ((-gptr- "const double *") w) 
    ((-int-) wstride)                     ;; size_t -> int
    ((-gptr- "const double *") y) 
    ((-int-) ystride)                     ;; size_t -> int
    ((-int-) n)                     ;; size_t -> int
    ((-gptr- "double *") c0) 
    ((-gptr- "double *") c1) 
    ((-gptr- "double *") cov00) 
    ((-gptr- "double *") cov01) 
    ((-gptr- "double *") cov11) 
    ((-gptr- "double *") chisq) 
    (int #{ gsl_fit_wlinear (  $x ,$xstride ,$w ,$wstride ,$y ,$ystride ,$n ,$c0 ,$c1 ,$cov00 ,$cov01 ,$cov11 ,$chisq) #} )
)


(de gsl_fit_linear_est (    x  c0  c1  c00  c01  c11   y   y_err )
    ((-double-) x) 
    ((-double-) c0) 
    ((-double-) c1) 
    ((-double-) c00) 
    ((-double-) c01) 
    ((-double-) c11) 
    ((-gptr- "double *") y) 
    ((-gptr- "double *") y_err) 
    (int #{ gsl_fit_linear_est (  $x ,$c0 ,$c1 ,$c00 ,$c01 ,$c11 ,$y ,$y_err) #} )
)



(de gsl_fit_mul (    x  xstride  y  ystride  n  c1  cov11  sumsq )
    ((-gptr- "const double *") x) 
    ((-int-) xstride)                     ;; size_t -> int
    ((-gptr- "const double *") y) 
    ((-int-) ystride)                     ;; size_t -> int
    ((-int-) n)                     ;; size_t -> int
    ((-gptr- "double *") c1) 
    ((-gptr- "double *") cov11) 
    ((-gptr- "double *") sumsq) 
    (int #{ gsl_fit_mul (  $x ,$xstride ,$y ,$ystride ,$n ,$c1 ,$cov11 ,$sumsq) #} )
)


(de gsl_fit_wmul (    x  xstride  w  wstride  y  ystride  n  c1  cov11  sumsq )
    ((-gptr- "const double *") x) 
    ((-int-) xstride)                     ;; size_t -> int
    ((-gptr- "const double *") w) 
    ((-int-) wstride)                     ;; size_t -> int
    ((-gptr- "const double *") y) 
    ((-int-) ystride)                     ;; size_t -> int
    ((-int-) n)                     ;; size_t -> int
    ((-gptr- "double *") c1) 
    ((-gptr- "double *") cov11) 
    ((-gptr- "double *") sumsq) 
    (int #{ gsl_fit_wmul (  $x ,$xstride ,$w ,$wstride ,$y ,$ystride ,$n ,$c1 ,$cov11 ,$sumsq) #} )
)



(de gsl_fit_mul_est (    x  c1  c11   y   y_err )
    ((-double-) x) 
    ((-double-) c1) 
    ((-double-) c11) 
    ((-gptr- "double *") y) 
    ((-gptr- "double *") y_err) 
    (int #{ gsl_fit_mul_est (  $x ,$c1 ,$c11 ,$y ,$y_err) #} )
)





(de gsl_fit_poly (    x  w  y  n  c  m  chisq )
    ((-gptr- "const double *") x) 
    ((-gptr- "const double *") w) 
    ((-gptr- "const double *") y) 
    ((-int-) n)                     ;; size_t -> int
    ((-gptr- "double *") c) 
    ((-int-) m)                     ;; size_t -> int
    ((-gptr- "double *") chisq) 
    (int #{ gsl_fit_poly (  $x ,$w ,$y ,$n ,$c ,$m ,$chisq) #} )
)


(de gsl_fit_fns (    a  w  y  n  c  m  chisq )
    ((-gptr- "const double *") a) 
    ((-gptr- "const double *") w) 
    ((-gptr- "const double *") y) 
    ((-int-) n)                     ;; size_t -> int
    ((-gptr- "double *") c) 
    ((-int-) m)                     ;; size_t -> int
    ((-gptr- "double *") chisq) 
    (int #{ gsl_fit_fns (  $a ,$w ,$y ,$n ,$c ,$m ,$chisq) #} )
)


(de gsl_fit_linear_nd (    m  y  w )
    ((-gptr- "double *") m) 
    ((-gptr- "double *") y) 
    ((-gptr- "double *") w) 
    (int #{ gsl_fit_linear_nd (  $m ,$y ,$w) #} )
)

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

(dhc-make ()
  dummy_fit
  gsl_fit_linear
  gsl_fit_wlinear
  gsl_fit_linear_est
  gsl_fit_mul
  gsl_fit_wmul
  gsl_fit_mul_est
;;  gsl_fit_poly
;;  gsl_fit_fns
;;  gsl_fit_linear_nd
)
