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



#? *** monte

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

#? * (dummy_monte)
#? * (gsl_monte_miser_integrate <f> <xl> <xh> <dim> <calls> <r> <state> <result> <abserr>)
#? * (gsl_monte_miser_alloc <dim>)
#? * (gsl_monte_miser_init <state>)
#? * (gsl_monte_miser_free <state>)
#? * (gsl_monte_plain_integrate <f> <xl> <xu> <dim> <calls> <r> <state> <result> <abserr>)
#? * (gsl_monte_plain_alloc <dim>)
#? * (gsl_monte_plain_init <state>)
#? * (gsl_monte_plain_free <state>)
#? * (gsl_monte_vegas_integrate <f> <xl> <xu> <dim> <calls> <r> <state> <result> <abserr>)
#? * (gsl_monte_vegas_alloc <dim>)
#? * (gsl_monte_vegas_init <state>)
#? * (gsl_monte_vegas_free <state>)

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



;;;;****************************************************************************************************
;;;;              gsl_monte_miser

(de gsl_monte_miser_integrate (    f  xl  xh  dim  calls   r  state   result   abserr )
    ((-gptr- "gsl_monte_function *") f) 
    ((-gptr- "const double *") xl) 
    ((-gptr- "const double *") xh) 
    ((-int-) dim)                     ;; size_t -> int
    ((-int-) calls)                     ;; size_t -> int
    ((-gptr- "gsl_rng *") r) 
    ((-gptr- "gsl_monte_miser_state*") state) 
    ((-gptr- "double *") result) 
    ((-gptr- "double *") abserr) 
    (int #{ gsl_monte_miser_integrate(  $f ,$xl ,$xh ,$dim ,$calls ,$r ,$state ,$result ,$abserr) #} )
)


(de gsl_monte_miser_alloc (    dim )
    ((-int-) dim)                     ;; size_t -> int
    (gptr #{ gsl_monte_miser_alloc(  $dim) #} )          ;; gsl_monte_miser_state * -> gptr
)


(de gsl_monte_miser_init (    state )
    ((-gptr- "gsl_monte_miser_state*") state) 
    (int #{ gsl_monte_miser_init(  $state) #} )
)


(de gsl_monte_miser_free (    state )
    ((-gptr- "gsl_monte_miser_state*") state) 
    #{ gsl_monte_miser_free(  $state) #} 
    ()
)


;;;;*****************************************************************************************************
;;;;              gsl_monte_plain


(de gsl_monte_plain_integrate (    f  xl  xu  dim  calls  r  state   result   abserr )
    ((-gptr- "const gsl_monte_function *") f) 
    ((-gptr- "const double *") xl) 
    ((-gptr- "const double *") xu) 
    ((-int-) dim)                     ;; size_t -> int
    ((-int-) calls)                     ;; size_t -> int
    ((-gptr- "gsl_rng *") r) 
    ((-gptr- "gsl_monte_plain_state *") state) 
    ((-gptr- "double *") result) 
    ((-gptr- "double *") abserr) 
    (int #{ gsl_monte_plain_integrate (  $f ,$xl ,$xu ,$dim ,$calls ,$r ,$state ,$result ,$abserr) #} )
)


(de gsl_monte_plain_alloc (    dim )
    ((-int-) dim)                     ;; size_t -> int
    (gptr #{ gsl_monte_plain_alloc(  $dim) #} )          ;; gsl_monte_plain_state* -> gptr
)


(de gsl_monte_plain_init (    state )
    ((-gptr- "gsl_monte_plain_state*") state) 
    (int #{ gsl_monte_plain_init(  $state) #} )
)


(de gsl_monte_plain_free (    state )
    ((-gptr- "gsl_monte_plain_state*") state) 
    #{ gsl_monte_plain_free (  $state) #} 
    ()
)

;;;;******************************************************************************************************
;;;;               gsl_monte_vegas


(de gsl_monte_vegas_integrate (    f  xl  xu  dim  calls  r   state  result  abserr )
    ((-gptr- "gsl_monte_function *") f) 
    ((-gptr- "double *") xl) 
    ((-gptr- "double *") xu) 
    ((-int-) dim)                     ;; size_t -> int
    ((-int-) calls)                     ;; size_t -> int
    ((-gptr- "gsl_rng *") r) 
    ((-gptr- "gsl_monte_vegas_state *") state) 
    ((-gptr- "double*") result) 
    ((-gptr- "double*") abserr) 
    (int #{ gsl_monte_vegas_integrate(  $f ,$xl ,$xu ,$dim ,$calls ,$r ,$state ,$result ,$abserr) #} )
)


(de gsl_monte_vegas_alloc (    dim )
    ((-int-) dim)                     ;; size_t -> int
    (gptr #{ gsl_monte_vegas_alloc(  $dim) #} )          ;; gsl_monte_vegas_state* -> gptr
)


(de gsl_monte_vegas_init (    state )
    ((-gptr- "gsl_monte_vegas_state*") state) 
    (int #{ gsl_monte_vegas_init(  $state) #} )
)


(de gsl_monte_vegas_free (    state )
    ((-gptr- "gsl_monte_vegas_state*") state) 
    #{ gsl_monte_vegas_free (  $state) #} 
    ()
)


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

(dhc-make ()
  dummy_monte
  gsl_monte_miser_integrate
  gsl_monte_miser_alloc
  gsl_monte_miser_init
  gsl_monte_miser_free
  gsl_monte_plain_integrate
  gsl_monte_plain_alloc
  gsl_monte_plain_init
  gsl_monte_plain_free
  gsl_monte_vegas_integrate
  gsl_monte_vegas_alloc
  gsl_monte_vegas_init
  gsl_monte_vegas_free
)
