Skip to content

Commit bb5100f

Browse files
committed
Update documentation.
1 parent 9349296 commit bb5100f

File tree

5 files changed

+49
-8
lines changed

5 files changed

+49
-8
lines changed

src/ArrayFire/BLAS.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ dotAll arr1 arr2 prop1 prop2 = do
123123
-- [3 2 1 1]
124124
-- 2.0000 4.0000 5.0000
125125
-- 3.0000 4.0000 6.0000
126+
--
126127
transpose
127128
:: Array a
128129
-- ^ Input matrix to be transposed
@@ -136,9 +137,11 @@ transpose arr1 (fromIntegral . fromEnum -> b) =
136137
-- | Transposes a matrix.
137138
--
138139
-- * Warning: This function mutates an array in-place, all subsequent references will be changed. Use carefully.
140+
--
139141
-- >>> array = matrix @Double (2,2) [[1..2],[3..4]]
140142
-- >>> transposeInPlace array False
141143
-- ()
144+
--
142145
transposeInPlace
143146
:: Array a
144147
-- ^ Input matrix to be transposed

src/ArrayFire/Data.hs

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ import ArrayFire.Internal.Defines
3939
import ArrayFire.Internal.Types
4040
import ArrayFire.Arith
4141

42-
-- | Creates an 'Array' 'Double' from a scalar value
42+
-- | Creates an 'Array' from a scalar value from given dimensions
4343
--
44-
-- @
45-
-- >>> 'constant' \@'Double' [2,2] 2.0
46-
-- @
44+
-- >>> constant @Double [2,2] 2.0
45+
-- ArrayFire Array
46+
-- [2 2 1 1]
47+
-- 2.0000 2.0000
48+
-- 2.0000 2.0000
4749
constant
4850
:: forall a . AFType a
4951
=> [Int]
@@ -356,6 +358,7 @@ joinMany (fromIntegral -> n) arrays = unsafePerformIO . mask_ $ do
356358
-- 22.0000 22.0000 22.0000 22.0000 22.0000
357359
-- 22.0000 22.0000 22.0000 22.0000 22.0000
358360
-- 22.0000 22.0000 22.0000 22.0000 22.0000
361+
--
359362
tile
360363
:: Array (a :: *)
361364
-> [Int]
@@ -375,6 +378,7 @@ tile _ _ = error "impossible"
375378
-- 22.0000 22.0000 22.0000 22.0000 22.0000
376379
-- 22.0000 22.0000 22.0000 22.0000 22.0000
377380
-- 22.0000 22.0000 22.0000 22.0000 22.0000
381+
--
378382
reorder
379383
:: Array (a :: *)
380384
-> [Int]
@@ -384,10 +388,12 @@ reorder a (take 4 . (++ repeat 0) -> [x,y,z,w]) =
384388
reorder _ _ = error "impossible"
385389

386390
-- | Shift elements in an Array along a specified dimension (elements will wrap).
391+
--
387392
-- >>> shift (vector @Double 4 [1..]) 2 0 0 0
388393
-- ArrayFire Array
389394
-- [4 1 1 1]
390395
-- 3.0000 4.0000 1.0000 2.0000
396+
--
391397
shift
392398
:: Array (a :: *)
393399
-> Int
@@ -406,6 +412,7 @@ shift a (fromIntegral -> x) (fromIntegral -> y) (fromIntegral -> z) (fromIntegra
406412
-- 1.0000
407413
-- 2.0000
408414
-- 3.0000
415+
--
409416
moddims
410417
:: forall a
411418
. Array (a :: *)
@@ -433,6 +440,7 @@ moddims (Array fptr) dims =
433440
-- ArrayFire Array
434441
-- [8 1 1 1]
435442
-- 1 1 1 1 1 1 1 1
443+
--
436444
flat
437445
:: Array a
438446
-> Array a
@@ -451,29 +459,58 @@ flat = (`op1` af_flat)
451459
-- [2 2 1 1]
452460
-- 3.0000 3.0000
453461
-- 2.0000 2.0000
462+
--
454463
flip
455464
:: Array a
456465
-> Int
457466
-> Array a
458467
flip a (fromIntegral -> dim) =
459468
a `op1` (\p k -> af_flip p k dim)
460469

470+
-- | Create a lower triangular matrix from input array.
471+
--
472+
-- >>> lower (constant [2,2] 10 :: Array Double) True
473+
-- ArrayFire Array
474+
-- [2 2 1 1]
475+
-- 1.0000 10.0000
476+
-- 0.0000 1.0000
477+
--
461478
lower
462479
:: Array a
480+
-- ^ is the input matrix
463481
-> Bool
482+
-- ^ 'is_unit_diag' is a boolean parameter specifying if the diagonal elements should be 1
464483
-> Array a
465484
lower a (fromIntegral . fromEnum -> b) =
466485
a `op1` (\p k -> af_lower p k b)
467486

487+
-- | Create an upper triangular matrix from input array.
488+
--
489+
-- >>> upper (constant [2,2] 10 :: Array Double) True
490+
-- ArrayFire Array
491+
-- [2 2 1 1]
492+
-- 1.0000 0.0000
493+
-- 10.0000 1.0000
494+
--
468495
upper
469496
:: Array a
470497
-> Bool
471498
-> Array a
472499
upper a (fromIntegral . fromEnum -> b) =
473500
a `op1` (\p k -> af_upper p k b)
474501

502+
-- | Selects elements from two arrays based on the values of a binary conditional array.
503+
--
504+
-- >>> cond = vector @CBool 5 [1,0,1,0,1]
505+
-- >>> arr1 = vector @Double 5 (repeat 1)
506+
-- >>> arr2 = vector @Double 5 (repeat 2)
507+
-- >>> select cond arr1 arr2
508+
-- ArrayFire Array
509+
-- [5 1 1 1]
510+
-- 1.0000 2.0000 1.0000 2.0000 1.0000
511+
--
475512
select
476-
:: Array a
513+
:: Array CBool
477514
-> Array a
478515
-> Array a
479516
-> Array a

src/ArrayFire/Exception.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ data AFExceptionType
6262
| UnhandledError
6363
deriving (Show, Eq, Typeable)
6464

65+
-- | Exception type for ArrayFire API
6566
data AFException
6667
= AFException
6768
{ afExceptionType :: AFExceptionType

src/ArrayFire/FFI.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import Foreign.Marshal.Alloc
3030
import System.IO.Unsafe
3131

3232
op3
33-
:: Array a
33+
:: Array b
3434
-> Array a
3535
-> Array a
3636
-> (Ptr AFArray -> AFArray -> AFArray -> AFArray -> IO AFErr)

test/Main.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ main = do
3232
-- checks (Proxy :: Proxy (A.Array A.Word8))
3333
-- checks (Proxy :: Proxy (A.Array A.Word16))
3434
-- checks (Proxy :: Proxy (A.Array A.Word32))
35-
-- lawsCheck $ semigroupLaws (Proxy :: Proxy (A.Array Double))
35+
lawsCheck $ semigroupLaws (Proxy :: Proxy (A.Array Double))
3636
-- lawsCheck $ semigroupLaws (Proxy :: Proxy (A.Array Float))
37-
hspec spec
37+
-- hspec spec
3838

3939
checks proxy = do
4040
lawsCheck (numLaws proxy)

0 commit comments

Comments
 (0)