From b5bc0c0bc71915093d0883e2fd923808ada4db6c Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 11 Feb 2013 09:34:30 -0500 Subject: [PATCH] Bump to fixed-vector-0.2.*. --- numerical-analysis.cabal | 2 +- src/Matrix.hs | 3 +-- src/Vector.hs | 17 ++++++++++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/numerical-analysis.cabal b/numerical-analysis.cabal index ff7aaaa..88455aa 100644 --- a/numerical-analysis.cabal +++ b/numerical-analysis.cabal @@ -22,7 +22,7 @@ library build-depends: base >= 3 && < 5, - fixed-vector == 0.1.*, + fixed-vector == 0.2.*, numbers == 3000.1.*, vector == 0.10.* diff --git a/src/Matrix.hs b/src/Matrix.hs index 5b55844..ae1c588 100644 --- a/src/Matrix.hs +++ b/src/Matrix.hs @@ -10,8 +10,7 @@ where import Vector import Data.Vector.Fixed ( Dim, - Vector, - (!), + Vector ) import qualified Data.Vector.Fixed as V ( fromList, diff --git a/src/Vector.hs b/src/Vector.hs index a4d3c13..1aaf78d 100644 --- a/src/Vector.hs +++ b/src/Vector.hs @@ -15,12 +15,12 @@ import Data.Vector.Fixed ( N3, N4, Vector(..), - (!), construct, inspect, toList, ) import qualified Data.Vector.Fixed as V ( + eq, foldl, length, map, @@ -81,8 +81,8 @@ instance (Show a, Vector v a) => Show (Vn v a) where -- >>> v1 == v3 -- False -- -instance (Eq a, Vector v a, Vector v Bool) => Eq (Vn v a) where - (Vn v1) == (Vn v2) = V.foldl (&&) True (V.zipWith (==) v1 v2) +instance (Eq a, Vector v a) => Eq (Vn v a) where + (Vn v1) == (Vn v2) = v1 `V.eq` v2 -- | The use of 'Num' here is of course incorrect (otherwise, we @@ -191,6 +191,17 @@ angle v1 v2 = norms = (norm v1) * (norm v2) +-- | Unsafe indexing. +-- +-- Examples: +-- +-- >>> let v1 = make2d (1,2) +-- >>> v1 ! 1 +-- 2 +-- +(!) :: (Vector v a) => v a -> Int -> a +(!) v1 idx = (toList v1) !! idx + -- | Safe indexing. -- -- Examples: -- 2.43.2