Skip to content

Commit b06a1f8

Browse files
authored
Validate Array in correct order. (#37)
1 parent c745f73 commit b06a1f8

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/ArrayFire/Array.hs

+13-12
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,19 @@ vector n = mkArray [n] . take n
7575

7676
-- | Smart constructor for creating a matrix 'Array'
7777
--
78-
-- >>> matrix @Double (2,2) [[1,2],[3,4]]
78+
-- >>> A.matrix @Double (3,2) [[1,2,3],[4,5,6]]
7979
-- ArrayFire Array
80-
-- [2 2 1 1]
81-
-- 1.0000 2.0000
82-
-- 3.0000 4.0000
80+
-- [3 2 1 1]
81+
-- 1.0000 4.0000
82+
-- 2.0000 5.0000
83+
-- 3.0000 6.0000
8384
--
8485
matrix :: AFType a => (Int,Int) -> [[a]] -> Array a
8586
matrix (x,y)
8687
= mkArray [x,y]
8788
. concat
88-
. take x
89-
. fmap (take y)
89+
. take y
90+
. fmap (take x)
9091

9192
-- | Smart constructor for creating a cubic 'Array'
9293
--
@@ -106,9 +107,9 @@ cube (x,y,z)
106107
= mkArray [x,y,z]
107108
. concat
108109
. fmap concat
109-
. take x
110+
. take z
110111
. fmap (take y)
111-
. (fmap . fmap . take) z
112+
. (fmap . fmap . take) x
112113

113114
-- | Smart constructor for creating a tensor 'Array'
114115
--
@@ -136,10 +137,10 @@ tensor (w,x,y,z)
136137
. concat
137138
. fmap concat
138139
. (fmap . fmap) concat
139-
. take w
140-
. (fmap . take) x
141-
. (fmap . fmap . take) y
142-
. (fmap . fmap . fmap . take) z
140+
. take z
141+
. (fmap . take) y
142+
. (fmap . fmap . take) x
143+
. (fmap . fmap . fmap . take) w
143144

144145
-- | Internal function for 'Array' construction
145146
--

0 commit comments

Comments
 (0)