From: Michael Orlitzky Date: Tue, 5 Feb 2013 01:41:36 +0000 (-0500) Subject: Add a 2D fixed-point doctest (example) to Vector.hs. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=6dbbf1130a3318a1cc408f948ac15e74090710ec;p=numerical-analysis.git Add a 2D fixed-point doctest (example) to Vector.hs. Remove unused imports. --- diff --git a/src/Matrix.hs b/src/Matrix.hs index ea44ae9..5b55844 100644 --- a/src/Matrix.hs +++ b/src/Matrix.hs @@ -9,7 +9,6 @@ where import Vector import Data.Vector.Fixed ( - Arity(..), Dim, Vector, (!), diff --git a/src/Vector.hs b/src/Vector.hs index b42932c..f55808b 100644 --- a/src/Vector.hs +++ b/src/Vector.hs @@ -11,7 +11,6 @@ import Data.List (intercalate) import Data.Vector.Fixed ( Dim, Fun(..), - N1, N2, N3, N4, @@ -217,6 +216,20 @@ angle v1 v2 = -- constructors, so you can pattern match out the individual -- components. +-- | 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) +-- data Vec2D a = Vec2D a a type instance Dim Vec2D = N2 instance Vector Vec2D a where