X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;ds=sidebyside;f=src%2FLinear%2FVector.hs;h=56bc2af84c1ffc71aa1e3646602e92b1d875e642;hb=c7b6b27f4304416dcec67519b710d090850c3caa;hp=9d43bfac3122e82824d6a6921b6b33d69ba821a2;hpb=ae914d13235a4582077a5cb2b1edd630d9c6ad62;p=numerical-analysis.git diff --git a/src/Linear/Vector.hs b/src/Linear/Vector.hs index 9d43bfa..56bc2af 100644 --- a/src/Linear/Vector.hs +++ b/src/Linear/Vector.hs @@ -2,6 +2,7 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} @@ -22,7 +23,7 @@ import Data.Vector.Fixed ( Vector(..), fromList, toList ) -import qualified Data.Vector.Fixed as V ( +import Data.Vector.Fixed ( (!), foldl, length ) @@ -32,7 +33,8 @@ import Data.Vector.Fixed.Boxed ( Vec3, Vec4, Vec5 ) -import NumericPrelude hiding ( abs ) +import NumericPrelude hiding ( abs, length, foldl ) + type Vec1 = Vec N1 @@ -51,8 +53,8 @@ type Vec1 = Vec N1 -- (!?) :: (Vector v a) => v a -> Int -> Maybe a (!?) v1 idx - | idx < 0 || idx >= V.length v1 = Nothing - | otherwise = Just $ v1 V.! idx + | idx < 0 || idx >= length v1 = Nothing + | otherwise = Just $ v1 ! idx -- | Remove an element of the given vector. @@ -77,7 +79,7 @@ delete v1 idx = rhalf' = tail rhalf --- | We provide our own sum because V.sum relies on a Num instance +-- | We provide our own sum because sum relies on a Num instance -- from the Prelude that we don't have. -- -- Examples: @@ -88,4 +90,4 @@ delete v1 idx = -- 6 -- element_sum :: (Additive.C a, Ring.C a, Vector v a) => v a -> a -element_sum = V.foldl (+) (fromInteger 0) +element_sum = foldl (+) (fromInteger 0)