diff options
author | Alberto Ruiz <aruiz@um.es> | 2008-11-14 12:24:15 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2008-11-14 12:24:15 +0000 |
commit | b69fa7ed53d52e812afd27547f4f63e74cfe5527 (patch) | |
tree | fbac193293d425361e491760d0cfe8d2839d5533 | |
parent | e1b4cc06a5f98e576524b37ad0d9132f0678d722 (diff) |
conj using mapVector
-rw-r--r-- | examples/benchmarks.hs | 2 | ||||
-rw-r--r-- | lib/Data/Packed/Internal/Matrix.hs | 7 | ||||
-rw-r--r-- | lib/Data/Packed/Internal/auxi.c | 12 | ||||
-rw-r--r-- | lib/Data/Packed/Internal/auxi.h | 2 |
4 files changed, 2 insertions, 21 deletions
diff --git a/examples/benchmarks.hs b/examples/benchmarks.hs index 0e95851..bffa221 100644 --- a/examples/benchmarks.hs +++ b/examples/benchmarks.hs | |||
@@ -45,6 +45,7 @@ bench1 = do | |||
45 | putStrLn "constant 5M:" | 45 | putStrLn "constant 5M:" |
46 | time $ print $ constant (1::Double) 5000001 @> 7 | 46 | time $ print $ constant (1::Double) 5000001 @> 7 |
47 | time $ print $ constant i 5000001 @> 7 | 47 | time $ print $ constant i 5000001 @> 7 |
48 | time $ print $ conj (constant i 5000001) @> 7 | ||
48 | 49 | ||
49 | sumVH v = go (d - 1) 0 | 50 | sumVH v = go (d - 1) 0 |
50 | where | 51 | where |
@@ -64,7 +65,6 @@ innerH u v = go (d - 1) 0 | |||
64 | -- sumVector = foldVectorG (\k v s -> v k + s) 0.0 | 65 | -- sumVector = foldVectorG (\k v s -> v k + s) 0.0 |
65 | sumVector = foldVector (+) 0.0 | 66 | sumVector = foldVector (+) 0.0 |
66 | 67 | ||
67 | |||
68 | -------------------------------------------------------------------------------- | 68 | -------------------------------------------------------------------------------- |
69 | 69 | ||
70 | bench2 = do | 70 | bench2 = do |
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index 09f081a..44204a1 100644 --- a/lib/Data/Packed/Internal/Matrix.hs +++ b/lib/Data/Packed/Internal/Matrix.hs | |||
@@ -297,12 +297,7 @@ subMatrix = subMatrixD | |||
297 | 297 | ||
298 | -- | obtains the complex conjugate of a complex vector | 298 | -- | obtains the complex conjugate of a complex vector |
299 | conj :: Vector (Complex Double) -> Vector (Complex Double) | 299 | conj :: Vector (Complex Double) -> Vector (Complex Double) |
300 | conj v = unsafePerformIO $ do | 300 | conj = mapVector conjugate |
301 | r <- createVector (dim v) | ||
302 | app2 cconjugate vec v vec r "cconjugate" | ||
303 | return r | ||
304 | foreign import ccall "auxi.h conjugate" cconjugate :: TCVCV | ||
305 | |||
306 | 301 | ||
307 | -- | creates a complex vector from vectors with real and imaginary parts | 302 | -- | creates a complex vector from vectors with real and imaginary parts |
308 | toComplex :: (Vector Double, Vector Double) -> Vector (Complex Double) | 303 | toComplex :: (Vector Double, Vector Double) -> Vector (Complex Double) |
diff --git a/lib/Data/Packed/Internal/auxi.c b/lib/Data/Packed/Internal/auxi.c index 562c804..5c06cb6 100644 --- a/lib/Data/Packed/Internal/auxi.c +++ b/lib/Data/Packed/Internal/auxi.c | |||
@@ -64,18 +64,6 @@ int submatrixR(int r1, int r2, int c1, int c2, KRMAT(x),RMAT(r)) { | |||
64 | OK | 64 | OK |
65 | } | 65 | } |
66 | 66 | ||
67 | |||
68 | int conjugate(KCVEC(x),CVEC(t)) { | ||
69 | REQUIRES(xn==tn,BAD_SIZE); | ||
70 | DEBUGMSG("conjugate"); | ||
71 | int k; | ||
72 | for (k=0; k<xn; k++) { | ||
73 | tp[k].dat[0] = xp[k].dat[0]; | ||
74 | tp[k].dat[1] = - xp[k].dat[1]; | ||
75 | } | ||
76 | OK | ||
77 | } | ||
78 | |||
79 | //--------------------------------------- | 67 | //--------------------------------------- |
80 | void asm_finit() { | 68 | void asm_finit() { |
81 | asm("finit"); | 69 | asm("finit"); |
diff --git a/lib/Data/Packed/Internal/auxi.h b/lib/Data/Packed/Internal/auxi.h index e5370b4..c234ef5 100644 --- a/lib/Data/Packed/Internal/auxi.h +++ b/lib/Data/Packed/Internal/auxi.h | |||
@@ -16,6 +16,4 @@ const char * gsl_strerror (const int gsl_errno); | |||
16 | 16 | ||
17 | int matrix_fscanf(char*filename, RMAT(a)); | 17 | int matrix_fscanf(char*filename, RMAT(a)); |
18 | 18 | ||
19 | int conjugate(KCVEC(x),CVEC(t)); | ||
20 | |||
21 | void asm_finit(); | 19 | void asm_finit(); |