From 5eda17c87d1feb20455f3012f98afbba4d3f2cb4 Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Wed, 14 May 2014 20:54:03 +0200 Subject: moved toScalar --- packages/hmatrix/src/Numeric/GSL/Vector.hs | 32 +------------ packages/hmatrix/src/Numeric/GSL/gsl-vector.c | 66 --------------------------- 2 files changed, 1 insertion(+), 97 deletions(-) (limited to 'packages/hmatrix') diff --git a/packages/hmatrix/src/Numeric/GSL/Vector.hs b/packages/hmatrix/src/Numeric/GSL/Vector.hs index 38c138b..27db6ae 100644 --- a/packages/hmatrix/src/Numeric/GSL/Vector.hs +++ b/packages/hmatrix/src/Numeric/GSL/Vector.hs @@ -27,7 +27,7 @@ import Numeric.GSL.Internal hiding (TV,TM,TCV,TCM) import Numeric.Vectorized( sumF, sumR, sumQ, sumC, prodF, prodR, prodQ, prodC, - FunCodeS(..), + FunCodeS(..), toScalarR, toScalarF, toScalarC, toScalarQ, FunCodeV(..), FunCodeSV(..), FunCodeVV(..) @@ -46,11 +46,6 @@ fromei x = fromIntegral (fromEnum x) :: CInt ------------------------------------------------------------------ -toScalarAux fun code v = unsafePerformIO $ do - r <- createVector 1 - app2 (fun (fromei code)) vec v vec r "toScalarAux" - return (r @> 0) - vectorMapAux fun code v = unsafePerformIO $ do r <- createVector (dim v) app2 (fun (fromei code)) vec v vec r "vectorMapAux" @@ -70,31 +65,6 @@ vectorZipAux fun code u v = unsafePerformIO $ do --------------------------------------------------------------------- --- | obtains different functions of a vector: norm1, norm2, max, min, posmax, posmin, etc. -toScalarR :: FunCodeS -> Vector Double -> Double -toScalarR oper = toScalarAux c_toScalarR (fromei oper) - -foreign import ccall unsafe "gsl-aux.h toScalarR" c_toScalarR :: CInt -> TVV - --- | obtains different functions of a vector: norm1, norm2, max, min, posmax, posmin, etc. -toScalarF :: FunCodeS -> Vector Float -> Float -toScalarF oper = toScalarAux c_toScalarF (fromei oper) - -foreign import ccall unsafe "gsl-aux.h toScalarF" c_toScalarF :: CInt -> TFF - --- | obtains different functions of a vector: only norm1, norm2 -toScalarC :: FunCodeS -> Vector (Complex Double) -> Double -toScalarC oper = toScalarAux c_toScalarC (fromei oper) - -foreign import ccall unsafe "gsl-aux.h toScalarC" c_toScalarC :: CInt -> TCVV - --- | obtains different functions of a vector: only norm1, norm2 -toScalarQ :: FunCodeS -> Vector (Complex Float) -> Float -toScalarQ oper = toScalarAux c_toScalarQ (fromei oper) - -foreign import ccall unsafe "gsl-aux.h toScalarQ" c_toScalarQ :: CInt -> TQVF - ------------------------------------------------------------------- -- | map of real vectors with given function vectorMapR :: FunCodeV -> Vector Double -> Vector Double diff --git a/packages/hmatrix/src/Numeric/GSL/gsl-vector.c b/packages/hmatrix/src/Numeric/GSL/gsl-vector.c index 7e3c548..1eaf66c 100644 --- a/packages/hmatrix/src/Numeric/GSL/gsl-vector.c +++ b/packages/hmatrix/src/Numeric/GSL/gsl-vector.c @@ -88,72 +88,6 @@ #define BAD_FILE 2003 - -int toScalarR(int code, KRVEC(x), RVEC(r)) { - REQUIRES(rn==1,BAD_SIZE); - DEBUGMSG("toScalarR"); - KDVVIEW(x); - double res; - switch(code) { - case 0: { res = gsl_blas_dnrm2(V(x)); break; } - case 1: { res = gsl_blas_dasum(V(x)); break; } - case 2: { res = gsl_vector_max_index(V(x)); break; } - case 3: { res = gsl_vector_max(V(x)); break; } - case 4: { res = gsl_vector_min_index(V(x)); break; } - case 5: { res = gsl_vector_min(V(x)); break; } - default: ERROR(BAD_CODE); - } - rp[0] = res; - OK -} - -int toScalarF(int code, KFVEC(x), FVEC(r)) { - REQUIRES(rn==1,BAD_SIZE); - DEBUGMSG("toScalarF"); - KFVVIEW(x); - float res; - switch(code) { - case 0: { res = gsl_blas_snrm2(V(x)); break; } - case 1: { res = gsl_blas_sasum(V(x)); break; } - case 2: { res = gsl_vector_float_max_index(V(x)); break; } - case 3: { res = gsl_vector_float_max(V(x)); break; } - case 4: { res = gsl_vector_float_min_index(V(x)); break; } - case 5: { res = gsl_vector_float_min(V(x)); break; } - default: ERROR(BAD_CODE); - } - rp[0] = res; - OK -} - - -int toScalarC(int code, KCVEC(x), RVEC(r)) { - REQUIRES(rn==1,BAD_SIZE); - DEBUGMSG("toScalarC"); - KCVVIEW(x); - double res; - switch(code) { - case 0: { res = gsl_blas_dznrm2(V(x)); break; } - case 1: { res = gsl_blas_dzasum(V(x)); break; } - default: ERROR(BAD_CODE); - } - rp[0] = res; - OK -} - -int toScalarQ(int code, KQVEC(x), FVEC(r)) { - REQUIRES(rn==1,BAD_SIZE); - DEBUGMSG("toScalarQ"); - KQVVIEW(x); - float res; - switch(code) { - case 0: { res = gsl_blas_scnrm2(V(x)); break; } - case 1: { res = gsl_blas_scasum(V(x)); break; } - default: ERROR(BAD_CODE); - } - rp[0] = res; - OK -} - inline double sign(double x) { if(x>0) { -- cgit v1.2.3