diff options
author | Alberto Ruiz <aruiz@um.es> | 2015-05-27 09:10:22 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2015-05-27 09:10:22 +0200 |
commit | c5795a191ded450987a30302c1d1fa4a265350ff (patch) | |
tree | e3f9f754de966189dab7e4cbdddf96a4750cace8 /packages/base/src/Data/Packed/Internal/Matrix.hs | |
parent | f3a044a6219bd098fe5d55ef427b9ae6fe360cb9 (diff) |
ccompare, cselect, toInt
Diffstat (limited to 'packages/base/src/Data/Packed/Internal/Matrix.hs')
-rw-r--r-- | packages/base/src/Data/Packed/Internal/Matrix.hs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/packages/base/src/Data/Packed/Internal/Matrix.hs b/packages/base/src/Data/Packed/Internal/Matrix.hs index 1679ea6..82a9d8f 100644 --- a/packages/base/src/Data/Packed/Internal/Matrix.hs +++ b/packages/base/src/Data/Packed/Internal/Matrix.hs | |||
@@ -268,6 +268,9 @@ class (Storable a) => Element a where | |||
268 | extractR :: Matrix a -> CInt -> Vector CInt -> CInt -> Vector CInt -> Matrix a | 268 | extractR :: Matrix a -> CInt -> Vector CInt -> CInt -> Vector CInt -> Matrix a |
269 | sortI :: Ord a => Vector a -> Vector CInt | 269 | sortI :: Ord a => Vector a -> Vector CInt |
270 | sortV :: Ord a => Vector a -> Vector a | 270 | sortV :: Ord a => Vector a -> Vector a |
271 | compareV :: Ord a => Vector a -> Vector a -> Vector CInt | ||
272 | selectV :: Vector CInt -> Vector a -> Vector a -> Vector a -> Vector a | ||
273 | |||
271 | 274 | ||
272 | instance Element Float where | 275 | instance Element Float where |
273 | transdata = transdataAux ctransF | 276 | transdata = transdataAux ctransF |
@@ -275,6 +278,9 @@ instance Element Float where | |||
275 | extractR = extractAux c_extractF | 278 | extractR = extractAux c_extractF |
276 | sortI = sortIdxF | 279 | sortI = sortIdxF |
277 | sortV = sortValF | 280 | sortV = sortValF |
281 | compareV = compareF | ||
282 | selectV = selectF | ||
283 | |||
278 | 284 | ||
279 | instance Element Double where | 285 | instance Element Double where |
280 | transdata = transdataAux ctransR | 286 | transdata = transdataAux ctransR |
@@ -282,6 +288,9 @@ instance Element Double where | |||
282 | extractR = extractAux c_extractD | 288 | extractR = extractAux c_extractD |
283 | sortI = sortIdxD | 289 | sortI = sortIdxD |
284 | sortV = sortValD | 290 | sortV = sortValD |
291 | compareV = compareD | ||
292 | selectV = selectD | ||
293 | |||
285 | 294 | ||
286 | instance Element (Complex Float) where | 295 | instance Element (Complex Float) where |
287 | transdata = transdataAux ctransQ | 296 | transdata = transdataAux ctransQ |
@@ -289,6 +298,9 @@ instance Element (Complex Float) where | |||
289 | extractR = extractAux c_extractQ | 298 | extractR = extractAux c_extractQ |
290 | sortI = undefined | 299 | sortI = undefined |
291 | sortV = undefined | 300 | sortV = undefined |
301 | compareV = undefined | ||
302 | selectV = selectQ | ||
303 | |||
292 | 304 | ||
293 | instance Element (Complex Double) where | 305 | instance Element (Complex Double) where |
294 | transdata = transdataAux ctransC | 306 | transdata = transdataAux ctransC |
@@ -296,6 +308,9 @@ instance Element (Complex Double) where | |||
296 | extractR = extractAux c_extractC | 308 | extractR = extractAux c_extractC |
297 | sortI = undefined | 309 | sortI = undefined |
298 | sortV = undefined | 310 | sortV = undefined |
311 | compareV = undefined | ||
312 | selectV = selectC | ||
313 | |||
299 | 314 | ||
300 | instance Element (CInt) where | 315 | instance Element (CInt) where |
301 | transdata = transdataAux ctransI | 316 | transdata = transdataAux ctransI |
@@ -303,6 +318,9 @@ instance Element (CInt) where | |||
303 | extractR = extractAux c_extractI | 318 | extractR = extractAux c_extractI |
304 | sortI = sortIdxI | 319 | sortI = sortIdxI |
305 | sortV = sortValI | 320 | sortV = sortValI |
321 | compareV = compareI | ||
322 | selectV = selectI | ||
323 | |||
306 | 324 | ||
307 | ------------------------------------------------------------------- | 325 | ------------------------------------------------------------------- |
308 | 326 | ||
@@ -502,3 +520,38 @@ foreign import ccall unsafe "sort_valuesI" c_sort_valI :: CV CInt (CV CInt (IO | |||
502 | 520 | ||
503 | -------------------------------------------------------------------------------- | 521 | -------------------------------------------------------------------------------- |
504 | 522 | ||
523 | compareG f u v = unsafePerformIO $ do | ||
524 | r <- createVector (dim v) | ||
525 | app3 f vec u vec v vec r "compareG" | ||
526 | return r | ||
527 | |||
528 | compareD = compareG c_compareD | ||
529 | compareF = compareG c_compareF | ||
530 | compareI = compareG c_compareI | ||
531 | |||
532 | foreign import ccall unsafe "compareD" c_compareD :: CV Double (CV Double (CV CInt (IO CInt))) | ||
533 | foreign import ccall unsafe "compareF" c_compareF :: CV Float (CV Float (CV CInt (IO CInt))) | ||
534 | foreign import ccall unsafe "compareI" c_compareI :: CV CInt (CV CInt (CV CInt (IO CInt))) | ||
535 | |||
536 | -------------------------------------------------------------------------------- | ||
537 | |||
538 | selectG f c u v w = unsafePerformIO $ do | ||
539 | r <- createVector (dim v) | ||
540 | app5 f vec c vec u vec v vec w vec r "selectG" | ||
541 | return r | ||
542 | |||
543 | selectD = selectG c_selectD | ||
544 | selectF = selectG c_selectF | ||
545 | selectI = selectG c_selectI | ||
546 | selectC = selectG c_selectC | ||
547 | selectQ = selectG c_selectQ | ||
548 | |||
549 | type Sel x = CV CInt (CV x (CV x (CV x (CV x (IO CInt))))) | ||
550 | |||
551 | foreign import ccall unsafe "chooseD" c_selectD :: Sel Double | ||
552 | foreign import ccall unsafe "chooseF" c_selectF :: Sel Float | ||
553 | foreign import ccall unsafe "chooseI" c_selectI :: Sel CInt | ||
554 | foreign import ccall unsafe "chooseC" c_selectC :: Sel (Complex Double) | ||
555 | foreign import ccall unsafe "chooseQ" c_selectQ :: Sel (Complex Float) | ||
556 | |||
557 | |||