@@ -66,7 +66,7 @@ sum x (fromIntegral -> n) = (x `op1` (\p a -> af_sum p a n))
6666
6767-- | Sum all of the elements in 'Array' along the specified dimension, using a default value for NaN
6868--
69- -- >>> A.sumNaN (A.vector @Double 10 [1..]) 0 0 .0
69+ -- >>> let nan = 0/0 in A.sumNaN (A.vector @Double 10 (nan : [1..])) 0 10 .0
7070-- ArrayFire Array
7171-- [1 1 1 1]
7272-- 55.0000
@@ -100,7 +100,7 @@ product x (fromIntegral -> n) = (x `op1` (\p a -> af_product p a n))
100100
101101-- | Product all of the elements in 'Array' along the specified dimension, using a default value for NaN
102102--
103- -- >>> A.productNaN (A.vector @Double 10 [1..]) 0 0 .0
103+ -- >>> let nan = 0/0 in A.productNaN (A.vector @Double 10 (nan : [1..])) 0 2 .0
104104-- ArrayFire Array
105105-- [1 1 1 1]
106106-- 3628800.0000
@@ -150,10 +150,10 @@ max x (fromIntegral -> n) = x `op1` (\p a -> af_max p a n)
150150
151151-- | Find if all elements in an 'Array' are 'True' along a dimension
152152--
153- -- >>> A.allTrue (A.vector @CBool 10 (repeat 0 )) 0
153+ -- >>> A.allTrue (A.vector @CBool 10 (repeat 1 )) 0
154154-- ArrayFire Array
155155-- [1 1 1 1]
156- -- 0
156+ -- 1
157157allTrue
158158 :: AFType a
159159 => Array a
@@ -212,7 +212,7 @@ sumAll = (`infoFromArray2` af_sum_all)
212212
213213-- | Sum all elements in an 'Array' along all dimensions, using a default value for NaN
214214--
215- -- >>> A.sumNaNAll (A.vector @Double 10 [1..]) 0.0
215+ -- >>> let nan = 0/0 in A.sumNaNAll (A.vector @Double 10 (nan : [1..]) ) 0.0
216216-- (55.0,0.0)
217217sumNaNAll
218218 :: (AFType a , Fractional a )
@@ -516,15 +516,15 @@ diff2 a (fromIntegral -> n) = a `op1` (\p x -> af_diff2 p x n)
516516
517517-- | Sort an Array along a specified dimension, specifying ordering of results (ascending / descending)
518518--
519- -- >>> A.sort (A.vector @Double 4 [ 2,4,3,1 ]) 0 True
519+ -- >>> A.sort (A.vector @Double 4 [ 2,4,3,1 ]) 0 Asc
520520-- ArrayFire Array
521521-- [4 1 1 1]
522522-- 1.0000
523523-- 2.0000
524524-- 3.0000
525525-- 4.0000
526526--
527- -- >>> A.sort (A.vector @Double 4 [ 2,4,3,1 ]) 0 False
527+ -- >>> A.sort (A.vector @Double 4 [ 2,4,3,1 ]) 0 Desc
528528-- ArrayFire Array
529529-- [4 1 1 1]
530530-- 4.0000
537537 -- ^ Input array
538538 -> Int
539539 -- ^ Dimension along `sort` is performed
540- -> Bool
540+ -> Order
541541 -- ^ Return results in ascending order
542542 -> Array a
543543 -- ^ Will contain sorted input
@@ -546,7 +546,7 @@ sort a (fromIntegral -> n) (fromIntegral . fromEnum -> b) =
546546
547547-- | Sort an 'Array' along a specified dimension, specifying ordering of results (ascending / descending), returns indices of sorted results
548548--
549- -- >>> A.sortIndex (A.vector @Double 4 [3,2,1,4]) 0 True
549+ -- >>> A.sortIndex (A.vector @Double 4 [3,2,1,4]) 0 Asc
550550-- (ArrayFire Array
551551-- [4 1 1 1]
552552-- 1.0000
@@ -566,13 +566,18 @@ sortIndex
566566 -- ^ Input array
567567 -> Int
568568 -- ^ Dimension along `sortIndex` is performed
569- -> Bool
569+ -> Order
570570 -- ^ Return results in ascending order
571571 -> (Array a , Array Word32 )
572572 -- ^ Contains the sorted, contains indices for original input
573573sortIndex a (fromIntegral -> n) (fromIntegral . fromEnum -> b) =
574574 a `op2p` (\ p1 p2 p3 -> af_sort_index p1 p2 p3 n b)
575575
576+
577+ -- | Data type for expressing sort order
578+ data Order = Desc | Asc
579+ deriving (Enum , Show , Eq )
580+
576581-- | Sort an 'Array' along a specified dimension by keys, specifying ordering of results (ascending / descending)
577582--
578583-- >>> A.sortByKey (A.vector @Double 4 [2,1,4,3]) (A.vector @Double 4 [10,9,8,7]) 0 True
@@ -597,7 +602,7 @@ sortByKey
597602 -- ^ Values input array
598603 -> Int
599604 -- ^ Dimension along which to perform the operation
600- -> Bool
605+ -> Order
601606 -- ^ Return results in ascending order
602607 -> (Array a , Array a )
603608sortByKey a1 a2 (fromIntegral -> n) (fromIntegral . fromEnum -> b) =
0 commit comments