#? * BLAS: Extra/Miscellaneous Functions
;;.AUTHOR Fu Jie Huang, Yann LeCun
;; This provides a complete interface to the FORTRAN BLAS
;; library of low-level linear algebra functions.

(libload "blas-config")

;; Check if we can short-circuit by just mod-loading the object file
(let* ((dhc-make-lushflags (concat dhc-make-lushflags blas-cflags))
       (objfile (dhc-make-test ())) )
  (when objfile
    (mod-load objfile)
    (mapcar mod-load (cons blas-libblas blas-libfortran))
    (exit) ) )


(de blas-x-dummy () (cheader "typedef int int_func();") ())

;;interface generated from LAPACK Fortran files automatically
;;Fu Jie Huang, 2002

#? (xerbla <srname>  <info>  )
;;.VP
;;*  =====================================================================
;;*  Purpose
;;*  =======
;;*
;;*  XERBLA  is an error handler for the LAPACK routines.
;;*  It is called by an LAPACK routine if an input parameter has an
;;*  invalid value.  A message is printed and execution stops.
;;*
;;*  Installers may consider modifying the STOP statement in order to
;;*  call system-specific exception-handling facilities.
;;*
;;*  Arguments
;;*  =========
;;*
;;*  SRNAME  (input) CHARACTER*6
;;*          The name of the routine which called XERBLA.
;;*
;;*  INFO    (input) INTEGER
;;*          The position of the invalid parameter in the parameter list
;;*          of the calling routine.
;;*
;;*
;;*  =====================================================================

(de xerbla (srname  info  )
	((-str-) srname)
	((-idx0- (-int-)) info )
	#{ xerbla_($srname->data, IDX_PTR($info,int)) #} ())

;;interface generated from LAPACK Fortran files automatically
;;Fu Jie Huang, 2002

#? (isamax <n>  <sx>  <incx>  )
;;.VP
;;*  =====================================================================
;;*
;;*     finds the index of element having max. absolute value.
;;*     jack dongarra, linpack, 3/11/78.
;;*     modified 3/93 to return if incx .le. 0.
;;*     modified 12/3/93, array(1) declarations changed to array(*)
;;*
;;*  =====================================================================

(de isamax (n  sx  incx  )
	((-idx0- (-int-)) n )
	((-idx1- (-float-)) sx )
	((-idx0- (-int-)) incx )
	(let ((rval 0))
	#{ $rval=isamax_(IDX_PTR($n,int), IDX_PTR($sx,float), IDX_PTR($incx,int)) #} rval))


#? (idamax <n>  <dx>  <incx>  )
;;.VP
;;*  =====================================================================
;;*
;;*     finds the index of element having max. absolute value.
;;*     jack dongarra, linpack, 3/11/78.
;;*     modified 3/93 to return if incx .le. 0.
;;*     modified 12/3/93, array(1) declarations changed to array(*)
;;*
;;*  =====================================================================

(de idamax (n  dx  incx  )
	((-idx0- (-int-)) n )
	((-idx1- (-double-)) dx )
	((-idx0- (-int-)) incx )
	(let ((rval 0))
	  ((-int-) rval)
	#{ $rval=idamax_(IDX_PTR($n,int), IDX_PTR($dx,double), IDX_PTR($incx,int)) #} rval))

#? (icamax <n>  <cx>  <incx>  )
;;.VP
;;*  =====================================================================
;;*
;;*     finds the index of element having max. absolute value.
;;*     jack dongarra, linpack, 3/11/78.
;;*     modified 3/93 to return if incx .le. 0.
;;*     modified 12/3/93, array(1) declarations changed to array(*)
;;*
;;*  =====================================================================

(de icamax (n  cx  incx  )
	((-idx0- (-int-)) n )
	((-idx2- (-float-)) cx )
	((-idx0- (-int-)) incx )
	(let ((rval 0))
	#{ $rval=icamax_(IDX_PTR($n,int), IDX_PTR($cx,float), IDX_PTR($incx,int)) #} rval))


#? (izamax <n>  <zx>  <incx>  )
;;.VP
;;*  =====================================================================
;;*
;;*     finds the index of element having max. absolute value.
;;*     jack dongarra, 1/15/85.
;;*     modified 3/93 to return if incx .le. 0.
;;*     modified 12/3/93, array(1) declarations changed to array(*)
;;*
;;*  =====================================================================

(de izamax (n  zx  incx  )
	((-idx0- (-int-)) n )
	((-idx2- (-double-)) zx)
	((-idx0- (-int-)) incx )
	(let ((rval 0))
	  ((-int-) rval)
	#{ $rval=izamax_(IDX_PTR($n,int), IDX_PTR($zx,double), IDX_PTR($incx,int)) #} rval))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(let ((dhc-make-lushflags (concat dhc-make-lushflags blas-cflags)))
  (dhc-make-with-libs  
   () 
   (cons blas-libblas blas-libfortran)
   blas-x-dummy xerbla isamax idamax icamax izamax))


