]> gitweb.michael.orlitzky.com - numerical-analysis.git/blobdiff - src/Linear/Vector.hs
Replace the whole Matrix implementation with something a little better.
[numerical-analysis.git] / src / Linear / Vector.hs
index ec6ebcbfba47722110a056e90fb2590f93c8ed7d..aa1568bec6c2ff3b8ed0baa724177349fb04e3bb 100644 (file)
@@ -9,17 +9,12 @@ where
 
 import Data.Vector.Fixed (
   Dim,
-  Fun(..),
   N1,
-  N2,
-  N3,
   N4,
   N5,
   S,
   Vector(..),
-  construct,
   fromList,
-  inspect,
   toList,
   )
 import qualified Data.Vector.Fixed as V (
@@ -31,43 +26,13 @@ type Vec1 = Vec N1
 type Vec4 = Vec N4
 type Vec5 = Vec N5
 
--- * Low-dimension vector wrappers.
---
--- These wrappers are instances of 'Vector', so they inherit all of
--- the userful instances defined above. But, they use fixed
--- constructors, so you can pattern match out the individual
--- components.
-
-data D1 a = D1 a deriving (Show, Eq)
-type instance Dim D1 = N1
-instance Vector D1 a where
-  inspect (D1 x) (Fun f) = f x
-  construct = Fun D1
-
-data D2 a = D2 a a deriving (Show, Eq)
-type instance Dim D2 = N2
-instance Vector D2 a where
-  inspect (D2 x y) (Fun f) = f x y
-  construct = Fun D2
-
-data D3 a = D3 a a a deriving (Show, Eq)
-type instance Dim D3 = N3
-instance Vector D3 a where
-  inspect (D3 x y z) (Fun f) = f x y z
-  construct = Fun D3
-
-data D4 a = D4 a a a a deriving (Show, Eq)
-type instance Dim D4 = N4
-instance Vector D4 a where
-  inspect (D4 w x y z) (Fun f) = f w x y z
-  construct = Fun D4
-
 
 -- | Unsafe indexing.
 --
 --   Examples:
 --
---   >>> let v1 = D2 1 2
+--   >>> import Data.Vector.Fixed (mk2)
+--   >>> let v1 = mk2 1 2 :: Vec2 Int
 --   >>> v1 ! 1
 --   2
 --
@@ -78,7 +43,8 @@ instance Vector D4 a where
 --
 --   Examples:
 --
---   >>> let v1 = D3 1 2 3
+--   >>> import Data.Vector.Fixed (mk3)
+--   >>> let v1 = mk3 1 2 3 :: Vec3 Int
 --   >>> v1 !? 2
 --   Just 3
 --   >>> v1 !? 3
@@ -94,9 +60,10 @@ instance Vector D4 a where
 --
 --   Examples:
 --
---   >>> let b = D3 1 2 3
---   >>> delete b 1 :: D2 Int
---   D2 1 3
+--   >>> import Data.Vector.Fixed (mk3)
+--   >>> let b = mk3 1 2 3 :: Vec3 Int
+--   >>> delete b 1 :: Vec2 Int
+--   fromList [1,3]
 --
 delete :: (Vector v a, Vector w a, Dim v ~ S (Dim w)) => v a -> Int -> w a
 delete v1 idx =