diff options
author | Tom Smeding <tom@tomsmeding.com> | 2024-06-09 23:09:19 +0200 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2024-06-09 23:09:19 +0200 |
commit | 1f3d57e13441f86b97ee7ff213bb4a677e31f2db (patch) | |
tree | e72bfd568b032a9af611118038c2eeb6f347ea22 /src/Data/Array/Nested/Internal/Mixed.hs | |
parent | c8f99847359a92289cf0ded280069794f6abae6a (diff) |
argmin and argmax
Diffstat (limited to 'src/Data/Array/Nested/Internal/Mixed.hs')
-rw-r--r-- | src/Data/Array/Nested/Internal/Mixed.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Data/Array/Nested/Internal/Mixed.hs b/src/Data/Array/Nested/Internal/Mixed.hs index 4746f31..31c4e55 100644 --- a/src/Data/Array/Nested/Internal/Mixed.hs +++ b/src/Data/Array/Nested/Internal/Mixed.hs @@ -788,6 +788,16 @@ mreshape sh' arr = miota :: (Enum a, PrimElt a) => SNat n -> Mixed '[Just n] a miota sn = fromPrimitive $ M_Primitive (SKnown sn :$% ZSX) (X.iota sn) +-- | Throws if the array is empty. +margMinPrim :: (PrimElt a, NumElt a) => Mixed sh a -> IIxX sh +margMinPrim (toPrimitive -> M_Primitive sh (XArray arr)) = + ixxFromList (ssxFromShape sh) (numEltArgMin arr) + +-- | Throws if the array is empty. +margMaxPrim :: (PrimElt a, NumElt a) => Mixed sh a -> IIxX sh +margMaxPrim (toPrimitive -> M_Primitive sh (XArray arr)) = + ixxFromList (ssxFromShape sh) (numEltArgMax arr) + mtoXArrayPrimP :: Mixed sh (Primitive a) -> (IShX sh, XArray sh a) mtoXArrayPrimP (M_Primitive sh arr) = (sh, arr) |