From bdd718066eeb1dffc790d7f48398f24b9201c6ea Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Wed, 14 May 2014 20:25:30 +0200 Subject: moved prod --- packages/hmatrix/src/Numeric/GSL/Vector.hs | 36 +----------------- packages/hmatrix/src/Numeric/GSL/gsl-vector.c | 54 --------------------------- 2 files changed, 1 insertion(+), 89 deletions(-) (limited to 'packages/hmatrix/src') diff --git a/packages/hmatrix/src/Numeric/GSL/Vector.hs b/packages/hmatrix/src/Numeric/GSL/Vector.hs index 33bd778..38c138b 100644 --- a/packages/hmatrix/src/Numeric/GSL/Vector.hs +++ b/packages/hmatrix/src/Numeric/GSL/Vector.hs @@ -26,6 +26,7 @@ import Data.Packed import Numeric.GSL.Internal hiding (TV,TM,TCV,TCM) import Numeric.Vectorized( sumF, sumR, sumQ, sumC, + prodF, prodR, prodQ, prodC, FunCodeS(..), FunCodeV(..), FunCodeSV(..), @@ -45,41 +46,6 @@ fromei x = fromIntegral (fromEnum x) :: CInt ------------------------------------------------------------------ --- | product of elements -prodF :: Vector Float -> Float -prodF x = unsafePerformIO $ do - r <- createVector 1 - app2 c_prodF vec x vec r "prodF" - return $ r @> 0 - --- | product of elements -prodR :: Vector Double -> Double -prodR x = unsafePerformIO $ do - r <- createVector 1 - app2 c_prodR vec x vec r "prodR" - return $ r @> 0 - --- | product of elements -prodQ :: Vector (Complex Float) -> Complex Float -prodQ x = unsafePerformIO $ do - r <- createVector 1 - app2 c_prodQ vec x vec r "prodQ" - return $ r @> 0 - --- | product of elements -prodC :: Vector (Complex Double) -> Complex Double -prodC x = unsafePerformIO $ do - r <- createVector 1 - app2 c_prodC vec x vec r "prodC" - return $ r @> 0 - -foreign import ccall unsafe "gsl-aux.h prodF" c_prodF :: TFF -foreign import ccall unsafe "gsl-aux.h prodR" c_prodR :: TVV -foreign import ccall unsafe "gsl-aux.h prodQ" c_prodQ :: TQVQV -foreign import ccall unsafe "gsl-aux.h prodC" c_prodC :: TCVCV - ------------------------------------------------------------------- - toScalarAux fun code v = unsafePerformIO $ do r <- createVector 1 app2 (fun (fromei code)) vec v vec r "toScalarAux" diff --git a/packages/hmatrix/src/Numeric/GSL/gsl-vector.c b/packages/hmatrix/src/Numeric/GSL/gsl-vector.c index 3c2db4d..7e3c548 100644 --- a/packages/hmatrix/src/Numeric/GSL/gsl-vector.c +++ b/packages/hmatrix/src/Numeric/GSL/gsl-vector.c @@ -88,60 +88,6 @@ #define BAD_FILE 2003 -int prodF(KFVEC(x),FVEC(r)) { - DEBUGMSG("prodF"); - REQUIRES(rn==1,BAD_SIZE); - int i; - float res = 1; - for (i = 0; i < xn; i++) res *= xp[i]; - rp[0] = res; - OK -} - -int prodR(KRVEC(x),RVEC(r)) { - DEBUGMSG("prodR"); - REQUIRES(rn==1,BAD_SIZE); - int i; - double res = 1; - for (i = 0; i < xn; i++) res *= xp[i]; - rp[0] = res; - OK -} - -int prodQ(KQVEC(x),QVEC(r)) { - DEBUGMSG("prodQ"); - REQUIRES(rn==1,BAD_SIZE); - int i; - gsl_complex_float res; - float temp; - res.dat[0] = 1; - res.dat[1] = 0; - for (i = 0; i < xn; i++) { - temp = res.dat[0] * xp[i].dat[0] - res.dat[1] * xp[i].dat[1]; - res.dat[1] = res.dat[0] * xp[i].dat[1] + res.dat[1] * xp[i].dat[0]; - res.dat[0] = temp; - } - rp[0] = res; - OK -} - -int prodC(KCVEC(x),CVEC(r)) { - DEBUGMSG("prodC"); - REQUIRES(rn==1,BAD_SIZE); - int i; - gsl_complex res; - double temp; - res.dat[0] = 1; - res.dat[1] = 0; - for (i = 0; i < xn; i++) { - temp = res.dat[0] * xp[i].dat[0] - res.dat[1] * xp[i].dat[1]; - res.dat[1] = res.dat[0] * xp[i].dat[1] + res.dat[1] * xp[i].dat[0]; - res.dat[0] = temp; - } - rp[0] = res; - OK -} - int toScalarR(int code, KRVEC(x), RVEC(r)) { REQUIRES(rn==1,BAD_SIZE); -- cgit v1.2.3