aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Mixed/Internal/Arith
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-06-09 23:09:19 +0200
committerTom Smeding <tom@tomsmeding.com>2024-06-09 23:09:19 +0200
commit1f3d57e13441f86b97ee7ff213bb4a677e31f2db (patch)
treee72bfd568b032a9af611118038c2eeb6f347ea22 /src/Data/Array/Mixed/Internal/Arith
parentc8f99847359a92289cf0ded280069794f6abae6a (diff)
argmin and argmax
Diffstat (limited to 'src/Data/Array/Mixed/Internal/Arith')
-rw-r--r--src/Data/Array/Mixed/Internal/Arith/Foreign.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Data/Array/Mixed/Internal/Arith/Foreign.hs b/src/Data/Array/Mixed/Internal/Arith/Foreign.hs
index 6fc7229..0bd72e8 100644
--- a/src/Data/Array/Mixed/Internal/Arith/Foreign.hs
+++ b/src/Data/Array/Mixed/Internal/Arith/Foreign.hs
@@ -53,3 +53,10 @@ $(fmap concat . forM typesList $ \arithtype -> do
let base = "reduce_" ++ atCName arithtype
pure . ForeignD . ImportF CCall Unsafe ("oxarop_" ++ base) (mkName ("c_" ++ base)) <$>
[t| CInt -> Int64 -> Ptr Int64 -> Ptr Int64 -> Ptr $ttyp -> Ptr $ttyp -> IO () |])
+
+$(fmap concat . forM typesList $ \arithtype ->
+ fmap concat . forM ["min", "max"] $ \fname -> do
+ let ttyp = conT (atType arithtype)
+ let base = "extremum_" ++ fname ++ "_" ++ atCName arithtype
+ pure . ForeignD . ImportF CCall Unsafe ("oxarop_" ++ base) (mkName ("c_" ++ base)) <$>
+ [t| Ptr Int64 -> Int64 -> Ptr Int64 -> Ptr Int64 -> Ptr $ttyp -> IO () |])