From ce8fed3a3558468b128a03cc4c96aa6c11357b4d Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Thu, 23 Oct 2008 13:30:33 +0000 Subject: NaN problem solved with asm(finit) --- lib/Numeric/LinearAlgebra/Algorithms.hs | 54 +------------------ lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c | 78 --------------------------- lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.h | 6 --- 3 files changed, 1 insertion(+), 137 deletions(-) (limited to 'lib/Numeric/LinearAlgebra') diff --git a/lib/Numeric/LinearAlgebra/Algorithms.hs b/lib/Numeric/LinearAlgebra/Algorithms.hs index 45298b5..e2fec9d 100644 --- a/lib/Numeric/LinearAlgebra/Algorithms.hs +++ b/lib/Numeric/LinearAlgebra/Algorithms.hs @@ -139,16 +139,8 @@ instance Field (Complex Double) where qr = unpackQR . qrC hess = unpackHess hessC schur = schurC - -#if defined(WORKAROUND) - multiply = mulCW -#else -#if defined(EXPOSEBUG) - multiply = multiplyC -#else multiply = multiplyC3 -#endif -#endif + -- | Eigenvalues and Eigenvectors of a complex hermitian or real symmetric matrix using lapack's dsyev or zheev. -- @@ -639,47 +631,3 @@ multiplyC3 x y = unsafePerformIO $ multiply3 zgemm "cblas_zgemm" (fmat x) (fmat return s -- if toLists s== toLists s then return s else error $ "HORROR " ++ (show (toLists s)) | otherwise = error $ st ++ " (matrix product) of nonconformant matrices" - ------------------------------------------------------------------------------------ --- BLAS via auxiliary C ------------------------------------------------------------------------------------ - --- foreign import ccall "multiply.h multiplyR2" dgemmc :: TMMM --- foreign import ccall "multiply.h multiplyC2" zgemmc :: TCMCMCM --- --- multiply2 f st a b --- | cols a == rows b = unsafePerformIO $ do --- s <- createMatrix ColumnMajor (rows a) (cols b) --- app3 f mat a mat b mat s st --- if toLists s== toLists s then return s else error $ "AYYY " ++ (show (toLists s)) --- | otherwise = error $ st ++ " (matrix product) of nonconformant matrices" --- --- multiplyR2 :: Matrix Double -> Matrix Double -> Matrix Double --- multiplyR2 a b = multiply2 dgemmc "dgemmc" (fmat a) (fmat b) --- --- multiplyC2 :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) --- multiplyC2 a b = multiply2 zgemmc "zgemmc" (fmat a) (fmat b) - ------------------------------------------------------------------------------------ --- direct C multiplication, to expose the NaN bug ------------------------------------------------------------------------------------ - --- foreign import ccall "multiply.h multiplyR" cmultiplyR :: TMMM -foreign import ccall "multiply.h multiplyC" cmultiplyC :: TCMCMCM - -cmultiply f st a b --- | cols a == rows b = - = unsafePerformIO $ do - s <- createMatrix RowMajor (rows a) (cols b) - app3 f mat a mat b mat s st - if toLists s== toLists s - then return s - else error $ "NaN FOUND!! " ++ (show (toLists s)) - -- return s --- | otherwise = error $ st ++ " (matrix product) of nonconformant matrices" - --- multiplyR :: Matrix Double -> Matrix Double -> Matrix Double --- multiplyR a b = cmultiply cmultiplyR "cmultiplyR" (cmat a) (cmat b) - -multiplyC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) -multiplyC a b = cmultiply cmultiplyC "cmultiplyR" (cmat a) (cmat b) diff --git a/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c b/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c index 61cb002..310f6ee 100644 --- a/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c +++ b/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c @@ -814,81 +814,3 @@ int lu_l_C(KCMAT(a), DVEC(ipiv), CMAT(r)) { free(auxipiv); OK } - -//////////////////////////////////////////////////////////// - -// int multiplyR(KDMAT(a),KDMAT(b),DMAT(r)) { -// REQUIRES(ac==br && ar==rr && bc==rc,BAD_SIZE); -// int i,j,k; -// for (i=0;i