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



#? *** eigen

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

#? * (dummy_eigen)
#? * (gsl_eigen_symm_alloc <n>)
#? * (gsl_eigen_symm_free <w>)
#? * (gsl_eigen_symm <a> <eval> <w>)
#? * (gsl_eigen_symmv_alloc <n>)
#? * (gsl_eigen_symmv_free <w>)
#? * (gsl_eigen_symmv <a> <eval> <evec> <w>)
#? * (gsl_eigen_herm_alloc <n>)
#? * (gsl_eigen_herm_free <w>)
#? * (gsl_eigen_herm <a> <eval> <w>)
#? * (gsl_eigen_hermv_alloc <n>)
#? * (gsl_eigen_hermv_free <w>)
#? * (gsl_eigen_hermv <a> <eval> <evec> <w>)
#? * (gsl_eigen_symmv_sort <eval> <evec> <sort_type>)
#? * (gsl_eigen_hermv_sort <eval> <evec> <sort_type>)
#? * (gsl_eigen_jacobi <matrix> <eval> <evec> <max_rot> <nrot>)
#? * (gsl_eigen_invert_jacobi <matrix> <ainv> <max_rot>)

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


(de gsl_eigen_symm_alloc (    n )
    ((-int-) n)                     ;; size_t -> int
    (gptr #{ gsl_eigen_symm_alloc (  $n) #} )          ;; gsl_eigen_symm_workspace * -> gptr
)

(de gsl_eigen_symm_free (    w )
    ((-gptr- "gsl_eigen_symm_workspace *") w) 
    #{ gsl_eigen_symm_free (  $w) #} 
    ()
)

(de gsl_eigen_symm (    a  eval  w )
    ((-gptr- "gsl_matrix *") a) 
    ((-gptr- "gsl_vector *") eval) 
    ((-gptr- "gsl_eigen_symm_workspace *") w) 
    (int #{ gsl_eigen_symm (  $a ,$eval ,$w) #} )
)


(de gsl_eigen_symmv_alloc (    n )
    ((-int-) n)                     ;; size_t -> int
    (gptr #{ gsl_eigen_symmv_alloc (  $n) #} )          ;; gsl_eigen_symmv_workspace * -> gptr
)

(de gsl_eigen_symmv_free (    w )
    ((-gptr- "gsl_eigen_symmv_workspace *") w) 
    #{ gsl_eigen_symmv_free (  $w) #} 
    ()
)

(de gsl_eigen_symmv (    a  eval  evec  w )
    ((-gptr- "gsl_matrix *") a) 
    ((-gptr- "gsl_vector *") eval) 
    ((-gptr- "gsl_matrix *") evec) 
    ((-gptr- "gsl_eigen_symmv_workspace *") w) 
    (int #{ gsl_eigen_symmv (  $a ,$eval ,$evec ,$w) #} )
)



(de gsl_eigen_herm_alloc (    n )
    ((-int-) n)                     ;; size_t -> int
    (gptr #{ gsl_eigen_herm_alloc (  $n) #} )          ;; gsl_eigen_herm_workspace * -> gptr
)

(de gsl_eigen_herm_free (    w )
    ((-gptr- "gsl_eigen_herm_workspace *") w) 
    #{ gsl_eigen_herm_free (  $w) #} 
    ()
)

(de gsl_eigen_herm (    a  eval  w )
    ((-gptr- "gsl_matrix_complex *") a) 
    ((-gptr- "gsl_vector *") eval) 
    ((-gptr- "gsl_eigen_herm_workspace *") w) 
    (int #{ gsl_eigen_herm (  $a ,$eval ,$w) #} )
)


(de gsl_eigen_hermv_alloc (    n )
    ((-int-) n)                     ;; size_t -> int
    (gptr #{ gsl_eigen_hermv_alloc (  $n) #} )          ;; gsl_eigen_hermv_workspace * -> gptr
)

(de gsl_eigen_hermv_free (    w )
    ((-gptr- "gsl_eigen_hermv_workspace *") w) 
    #{ gsl_eigen_hermv_free (  $w) #} 
    ()
)

(de gsl_eigen_hermv (    a  eval  evec  w )
    ((-gptr- "gsl_matrix_complex *") a) 
    ((-gptr- "gsl_vector *") eval) 
    ((-gptr- "gsl_matrix_complex *") evec) 
    ((-gptr- "gsl_eigen_hermv_workspace *") w) 
    (int #{ gsl_eigen_hermv (  $a ,$eval ,$evec ,$w) #} )
)





(de gsl_eigen_symmv_sort (    eval  evec  sort_type )
    ((-gptr- "gsl_vector *") eval) 
    ((-gptr- "gsl_matrix *") evec) 
    ((-int-) sort_type)                   ;; gsl_eigen_sort_t -> int
    (int #{ gsl_eigen_symmv_sort(  $eval ,$evec ,$sort_type) #} )
)


(de gsl_eigen_hermv_sort (    eval  evec  sort_type )
    ((-gptr- "gsl_vector *") eval) 
    ((-gptr- "gsl_matrix_complex *") evec) 
    ((-int-) sort_type)                      ;; gsl_eigen_sort_t -> int
    (int #{ gsl_eigen_hermv_sort(  $eval ,$evec ,$sort_type) #} )
)






(de gsl_eigen_jacobi (    matrix  eval  evec  max_rot  nrot )
    ((-gptr- "gsl_matrix *") matrix) 
    ((-gptr- "gsl_vector *") eval) 
    ((-gptr- "gsl_matrix *") evec) 
    ((-int-) max_rot)                                  ;; unsigned -> signed
    ((-gptr- "unsigned int *") nrot) 
    (int #{ gsl_eigen_jacobi(  $matrix ,$eval ,$evec ,$max_rot ,$nrot) #} )
)




(de gsl_eigen_invert_jacobi (    matrix  ainv  max_rot )
    ((-gptr- "const gsl_matrix *") matrix) 
    ((-gptr- "gsl_matrix *") ainv) 
    ((-int-) max_rot)                                  ;; unsigned -> signed
    (int #{ gsl_eigen_invert_jacobi(  $matrix ,$ainv ,$max_rot) #} )
)


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

(dhc-make ()
  dummy_eigen
  gsl_eigen_symm_alloc
  gsl_eigen_symm_free
  gsl_eigen_symm
  gsl_eigen_symmv_alloc
  gsl_eigen_symmv_free
  gsl_eigen_symmv
  gsl_eigen_herm_alloc
  gsl_eigen_herm_free
  gsl_eigen_herm
  gsl_eigen_hermv_alloc
  gsl_eigen_hermv_free
  gsl_eigen_hermv
  gsl_eigen_symmv_sort
  gsl_eigen_hermv_sort
  gsl_eigen_jacobi
  gsl_eigen_invert_jacobi
)
