]> gitweb.michael.orlitzky.com - numerical-analysis.git/blobdiff - src/Linear/Vector.hs
Fix compiler warnings and doctests.
[numerical-analysis.git] / src / Linear / Vector.hs
index 9774dcd40c8132413ddd541a2a65be8976a462e1..aba9e5fb2d28d3d5ae43665ca95353f3cc8b6fd5 100644 (file)
@@ -7,7 +7,6 @@
 module Linear.Vector
 where
 
-import Data.List (intercalate)
 import Data.Vector.Fixed (
   Dim,
   Fun(..),
@@ -24,8 +23,6 @@ import qualified Data.Vector.Fixed as V (
   length,
   )
 
-import Normed
-
 
 -- * Low-dimension vector wrappers.
 --
@@ -63,7 +60,7 @@ instance Vector D4 a where
 --
 --   Examples:
 --
---   >>> let v1 = Vec2D 1 2
+--   >>> let v1 = D2 1 2
 --   >>> v1 ! 1
 --   2
 --
@@ -74,7 +71,7 @@ instance Vector D4 a where
 --
 --   Examples:
 --
---   >>> let v1 = Vec3D 1 2 3
+--   >>> let v1 = D3 1 2 3
 --   >>> v1 !? 2
 --   Just 3
 --   >>> v1 !? 3
@@ -84,54 +81,3 @@ instance Vector D4 a where
 (!?) v1 idx
   | idx < 0 || idx >= V.length v1 = Nothing
   | otherwise                     = Just $ v1 ! idx
-
-
-
-
---instance (RealFloat a, Ord a, Vector v a) => Normed (Vn v a) where
-  -- | The infinity norm. We don't use V.maximum here because it
-  --   relies on a type constraint that the vector be non-empty and I
-  --   don't know how to pattern match it away.
-  --
-  --   Examples:
-  --
-  --   >>> let v1 = make3d (1,5,2)
-  --   >>> norm_infty v1
-  --   5
-  --
---  norm_infty (Vn v1) = realToFrac $ V.foldl max 0 v1
-
-  -- | Generic p-norms. The usual norm in R^n is (norm_p 2).
-  --
-  --   Examples:
-  --
-  --   >>> let v1 = make2d (3,4)
-  --   >>> norm_p 1 v1
-  --   7.0
-  --   >>> norm_p 2 v1
-  --   5.0
-  --
---  norm_p p (Vn v1) =
---    realToFrac $ root $ V.sum $ V.map (exponentiate . abs) v1
---    where
---      exponentiate = (** (fromIntegral p))
---      root = (** (recip (fromIntegral p)))
-
-
-
-
-
--- | Convenient constructor for 2D vectors.
---
---   Examples:
---
---   >>> import Roots.Simple
---   >>> let h = 0.5 :: Double
---   >>> let g1 (Vn (Vec2D x y)) = 1.0 + h*exp(-(x^2))/(1.0 + y^2)
---   >>> let g2 (Vn (Vec2D x y)) = 0.5 + h*atan(x^2 + y^2)
---   >>> let g u = make2d ((g1 u), (g2 u))
---   >>> let u0 = make2d (1.0, 1.0)
---   >>> let eps = 1/(10^9)
---   >>> fixed_point g eps u0
---   (1.0728549599342185,1.0820591495686167)
---