diff options
Diffstat (limited to 'packages/base/src')
-rw-r--r-- | packages/base/src/C/vector-aux.c | 13 | ||||
-rw-r--r-- | packages/base/src/Data/Packed/Internal/Numeric.hs | 2 | ||||
-rw-r--r-- | packages/base/src/Data/Packed/Numeric.hs | 2 | ||||
-rw-r--r-- | packages/base/src/Numeric/LinearAlgebra/Data.hs | 1 | ||||
-rw-r--r-- | packages/base/src/Numeric/Vectorized.hs | 12 |
5 files changed, 29 insertions, 1 deletions
diff --git a/packages/base/src/C/vector-aux.c b/packages/base/src/C/vector-aux.c index 53b56aa..b176089 100644 --- a/packages/base/src/C/vector-aux.c +++ b/packages/base/src/C/vector-aux.c | |||
@@ -770,3 +770,16 @@ int smTXv(KDVEC(vals),KIVEC(cols),KIVEC(rows),KDVEC(x),DVEC(r)) { | |||
770 | OK | 770 | OK |
771 | } | 771 | } |
772 | 772 | ||
773 | //////////////////////////////////////////////////////////////////////////////// | ||
774 | |||
775 | int | ||
776 | compare_doubles (const void *a, const void *b) { | ||
777 | return *(double*)a > *(double*)b; | ||
778 | } | ||
779 | |||
780 | int sort_values(KDVEC(v),DVEC(r)) { | ||
781 | memcpy(rp,vp,vn*sizeof(double)); | ||
782 | qsort(rp,rn,sizeof(double),compare_doubles); | ||
783 | OK | ||
784 | } | ||
785 | |||
diff --git a/packages/base/src/Data/Packed/Internal/Numeric.hs b/packages/base/src/Data/Packed/Internal/Numeric.hs index 0205a17..56ecdfe 100644 --- a/packages/base/src/Data/Packed/Internal/Numeric.hs +++ b/packages/base/src/Data/Packed/Internal/Numeric.hs | |||
@@ -30,6 +30,8 @@ module Data.Packed.Internal.Numeric ( | |||
30 | Product(..), udot, | 30 | Product(..), udot, |
31 | mXm,mXv,vXm, | 31 | mXm,mXv,vXm, |
32 | outer, kronecker, | 32 | outer, kronecker, |
33 | -- * sorting | ||
34 | sortVector, | ||
33 | -- * Element conversion | 35 | -- * Element conversion |
34 | Convert(..), | 36 | Convert(..), |
35 | Complexable(), | 37 | Complexable(), |
diff --git a/packages/base/src/Data/Packed/Numeric.hs b/packages/base/src/Data/Packed/Numeric.hs index e59c1cd..cc26d7a 100644 --- a/packages/base/src/Data/Packed/Numeric.hs +++ b/packages/base/src/Data/Packed/Numeric.hs | |||
@@ -51,6 +51,8 @@ module Data.Packed.Numeric ( | |||
51 | gaussianSample, | 51 | gaussianSample, |
52 | uniformSample, | 52 | uniformSample, |
53 | meanCov, | 53 | meanCov, |
54 | -- * sorting | ||
55 | sortVector, | ||
54 | -- * Element conversion | 56 | -- * Element conversion |
55 | Convert(..), | 57 | Convert(..), |
56 | Complexable(), | 58 | Complexable(), |
diff --git a/packages/base/src/Numeric/LinearAlgebra/Data.hs b/packages/base/src/Numeric/LinearAlgebra/Data.hs index 4e4868a..5099445 100644 --- a/packages/base/src/Numeric/LinearAlgebra/Data.hs +++ b/packages/base/src/Numeric/LinearAlgebra/Data.hs | |||
@@ -47,6 +47,7 @@ module Numeric.LinearAlgebra.Data( | |||
47 | 47 | ||
48 | -- * Find elements | 48 | -- * Find elements |
49 | find, maxIndex, minIndex, maxElement, minElement, atIndex, | 49 | find, maxIndex, minIndex, maxElement, minElement, atIndex, |
50 | sortVector, | ||
50 | 51 | ||
51 | -- * Sparse | 52 | -- * Sparse |
52 | AssocMatrix, toDense, | 53 | AssocMatrix, toDense, |
diff --git a/packages/base/src/Numeric/Vectorized.hs b/packages/base/src/Numeric/Vectorized.hs index 5aebb14..82504a9 100644 --- a/packages/base/src/Numeric/Vectorized.hs +++ b/packages/base/src/Numeric/Vectorized.hs | |||
@@ -18,7 +18,8 @@ module Numeric.Vectorized ( | |||
18 | FunCodeSV(..), vectorMapValR, vectorMapValC, vectorMapValF, vectorMapValQ, | 18 | FunCodeSV(..), vectorMapValR, vectorMapValC, vectorMapValF, vectorMapValQ, |
19 | FunCodeVV(..), vectorZipR, vectorZipC, vectorZipF, vectorZipQ, | 19 | FunCodeVV(..), vectorZipR, vectorZipC, vectorZipF, vectorZipQ, |
20 | vectorScan, saveMatrix, | 20 | vectorScan, saveMatrix, |
21 | Seed, RandDist(..), randomVector | 21 | Seed, RandDist(..), randomVector, |
22 | sortVector | ||
22 | ) where | 23 | ) where |
23 | 24 | ||
24 | import Data.Packed.Internal.Common | 25 | import Data.Packed.Internal.Common |
@@ -344,3 +345,12 @@ randomVector seed dist n = unsafePerformIO $ do | |||
344 | 345 | ||
345 | foreign import ccall unsafe "random_vector" c_random_vector :: CInt -> CInt -> TV | 346 | foreign import ccall unsafe "random_vector" c_random_vector :: CInt -> CInt -> TV |
346 | 347 | ||
348 | -------------------------------------------------------------------------------- | ||
349 | |||
350 | sortVector v = unsafePerformIO $ do | ||
351 | r <- createVector (dim v) | ||
352 | app2 c_sort_values vec v vec r "sortVector" | ||
353 | return r | ||
354 | |||
355 | foreign import ccall unsafe "sort_values" c_sort_values :: TVV | ||
356 | |||