summaryrefslogtreecommitdiff
path: root/packages/base/src/Data/Packed/Internal/Matrix.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2015-05-27 09:10:22 +0200
committerAlberto Ruiz <aruiz@um.es>2015-05-27 09:10:22 +0200
commitc5795a191ded450987a30302c1d1fa4a265350ff (patch)
treee3f9f754de966189dab7e4cbdddf96a4750cace8 /packages/base/src/Data/Packed/Internal/Matrix.hs
parentf3a044a6219bd098fe5d55ef427b9ae6fe360cb9 (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.hs53
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
272instance Element Float where 275instance 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
279instance Element Double where 285instance 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
286instance Element (Complex Float) where 295instance 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
293instance Element (Complex Double) where 305instance 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
300instance Element (CInt) where 315instance 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
523compareG f u v = unsafePerformIO $ do
524 r <- createVector (dim v)
525 app3 f vec u vec v vec r "compareG"
526 return r
527
528compareD = compareG c_compareD
529compareF = compareG c_compareF
530compareI = compareG c_compareI
531
532foreign import ccall unsafe "compareD" c_compareD :: CV Double (CV Double (CV CInt (IO CInt)))
533foreign import ccall unsafe "compareF" c_compareF :: CV Float (CV Float (CV CInt (IO CInt)))
534foreign import ccall unsafe "compareI" c_compareI :: CV CInt (CV CInt (CV CInt (IO CInt)))
535
536--------------------------------------------------------------------------------
537
538selectG 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
543selectD = selectG c_selectD
544selectF = selectG c_selectF
545selectI = selectG c_selectI
546selectC = selectG c_selectC
547selectQ = selectG c_selectQ
548
549type Sel x = CV CInt (CV x (CV x (CV x (CV x (IO CInt)))))
550
551foreign import ccall unsafe "chooseD" c_selectD :: Sel Double
552foreign import ccall unsafe "chooseF" c_selectF :: Sel Float
553foreign import ccall unsafe "chooseI" c_selectI :: Sel CInt
554foreign import ccall unsafe "chooseC" c_selectC :: Sel (Complex Double)
555foreign import ccall unsafe "chooseQ" c_selectQ :: Sel (Complex Float)
556
557