mk2,
mk3,
mk4,
- mk5
- )
+ mk5 )
import qualified Data.Vector.Fixed as V (
and,
fromList,
map,
maximum,
replicate,
+ reverse,
toList,
zipWith )
import Data.Vector.Fixed.Cont ( Arity, arity )
-- Examples:
--
-- >>> let m = fromList [[1,2,3],[4,5,6],[7,8,9]] :: Mat3 Int
--- >>> ifoldl2 (\i j cur _ -> cur + i + j) 0 m
+-- >>> ifoldl2 (\i j cur _ -> cur + i + j) 0 m
-- 18
--
ifoldl2 :: forall a b m n.
Mat $ V.imap g rows
where
g i = V.imap (f i)
+
+
+-- | Reverse the order of elements in a matrix.
+--
+-- Examples:
+--
+-- >>> let m1 = fromList [[1,2,3]] :: Row3 Int
+-- >>> reverse2 m1
+-- ((3,2,1))
+--
+-- >>> let m1 = vec3d (1,2,3 :: Int)
+-- >>> reverse2 m1
+-- ((3),(2),(1))
+--
+-- >>> let m = fromList [[1,2,3],[4,5,6],[7,8,9]] :: Mat3 Int
+-- >>> reverse2 m
+-- ((9,8,7),(6,5,4),(3,2,1))
+--
+reverse2 :: (Arity m, Arity n) => Mat m n a -> Mat m n a
+reverse2 (Mat rows) = Mat $ V.reverse $ V.map V.reverse rows