summaryrefslogtreecommitdiff
path: root/packages/base/src/Data/Packed/Internal/Matrix.hs
diff options
context:
space:
mode:
Diffstat (limited to 'packages/base/src/Data/Packed/Internal/Matrix.hs')
-rw-r--r--packages/base/src/Data/Packed/Internal/Matrix.hs40
1 files changed, 38 insertions, 2 deletions
diff --git a/packages/base/src/Data/Packed/Internal/Matrix.hs b/packages/base/src/Data/Packed/Internal/Matrix.hs
index 76d2204..1679ea6 100644
--- a/packages/base/src/Data/Packed/Internal/Matrix.hs
+++ b/packages/base/src/Data/Packed/Internal/Matrix.hs
@@ -265,33 +265,44 @@ class (Storable a) => Element a where
265 transdata = transdataP -- transdata' 265 transdata = transdataP -- transdata'
266 constantD :: a -> Int -> Vector a 266 constantD :: a -> Int -> Vector a
267 constantD = constantP -- constant' 267 constantD = constantP -- constant'
268 extractR :: Matrix a -> CInt -> Idxs -> CInt -> Idxs -> Matrix a 268 extractR :: Matrix a -> CInt -> Vector CInt -> CInt -> Vector CInt -> Matrix a
269 sortI :: Ord a => Vector a -> Vector CInt
270 sortV :: Ord a => Vector a -> Vector a
269 271
270instance Element Float where 272instance Element Float where
271 transdata = transdataAux ctransF 273 transdata = transdataAux ctransF
272 constantD = constantAux cconstantF 274 constantD = constantAux cconstantF
273 extractR = extractAux c_extractF 275 extractR = extractAux c_extractF
276 sortI = sortIdxF
277 sortV = sortValF
274 278
275instance Element Double where 279instance Element Double where
276 transdata = transdataAux ctransR 280 transdata = transdataAux ctransR
277 constantD = constantAux cconstantR 281 constantD = constantAux cconstantR
278 extractR = extractAux c_extractD 282 extractR = extractAux c_extractD
283 sortI = sortIdxD
284 sortV = sortValD
279 285
280instance Element (Complex Float) where 286instance Element (Complex Float) where
281 transdata = transdataAux ctransQ 287 transdata = transdataAux ctransQ
282 constantD = constantAux cconstantQ 288 constantD = constantAux cconstantQ
283 extractR = extractAux c_extractQ 289 extractR = extractAux c_extractQ
290 sortI = undefined
291 sortV = undefined
284 292
285instance Element (Complex Double) where 293instance Element (Complex Double) where
286 transdata = transdataAux ctransC 294 transdata = transdataAux ctransC
287 constantD = constantAux cconstantC 295 constantD = constantAux cconstantC
288 extractR = extractAux c_extractC 296 extractR = extractAux c_extractC
297 sortI = undefined
298 sortV = undefined
289 299
290instance Element (CInt) where 300instance Element (CInt) where
291 transdata = transdataAux ctransI 301 transdata = transdataAux ctransI
292 constantD = constantAux cconstantI 302 constantD = constantAux cconstantI
293 extractR = extractAux c_extractI 303 extractR = extractAux c_extractI
294 304 sortI = sortIdxI
305 sortV = sortValI
295 306
296------------------------------------------------------------------- 307-------------------------------------------------------------------
297 308
@@ -466,3 +477,28 @@ foreign import ccall unsafe "extractQ" c_extractQ
466foreign import ccall unsafe "extractI" c_extractI 477foreign import ccall unsafe "extractI" c_extractI
467 :: CInt -> CInt -> CInt -> CIdxs (CIdxs (CM CInt (CM CInt (IO CInt)))) 478 :: CInt -> CInt -> CInt -> CIdxs (CIdxs (CM CInt (CM CInt (IO CInt))))
468 479
480--------------------------------------------------------------------------------
481
482sortG f v = unsafePerformIO $ do
483 r <- createVector (dim v)
484 app2 f vec v vec r "sortG"
485 return r
486
487sortIdxD = sortG c_sort_indexD
488sortIdxF = sortG c_sort_indexF
489sortIdxI = sortG c_sort_indexI
490
491sortValD = sortG c_sort_valD
492sortValF = sortG c_sort_valF
493sortValI = sortG c_sort_valI
494
495foreign import ccall unsafe "sort_indexD" c_sort_indexD :: CV Double (CV CInt (IO CInt))
496foreign import ccall unsafe "sort_indexF" c_sort_indexF :: CV Float (CV CInt (IO CInt))
497foreign import ccall unsafe "sort_indexI" c_sort_indexI :: CV CInt (CV CInt (IO CInt))
498
499foreign import ccall unsafe "sort_valuesD" c_sort_valD :: CV Double (CV Double (IO CInt))
500foreign import ccall unsafe "sort_valuesF" c_sort_valF :: CV Float (CV Float (IO CInt))
501foreign import ccall unsafe "sort_valuesI" c_sort_valI :: CV CInt (CV CInt (IO CInt))
502
503--------------------------------------------------------------------------------
504