module GeomAlg.PointN (
module GeomAlg.Point,
module GeomAlg.PointN) where
import GeomAlg.Point
import Array (Array, elems, listArray, bounds, (!))
newtype PointN a = PointN (Array Int a) deriving Eq
instance (Show a, Num a) => Show (PointN a) where
showsPrec d (PointN xs) = showsPrec d (elems xs)
pointN xs = PointN (listArray (1,length xs) xs)
instance Functor PointN where
fmap f (PointN a) = PointN (fmap f a)
instance Point PointN where
dimension (PointN a) = snd (bounds a)
ith i (PointN a) = a ! i
origin = error "Point.PointN no origin"
(PointN x) <==> (PointN y)
| bounds x == bounds y = and (zipWith (==) (elems x) (elems y))
| otherwise = error "Point.PointN dimension /="
(PointN x) <+> (PointN y)
| bounds x == bounds y = pointN (zipWith (+) (elems x) (elems y))
| otherwise = error "Point.PointN dimension /="
(PointN x) <.> (PointN y)
| bounds x ==bounds y = sum (zipWith (*) (elems x) (elems y))
| otherwise = error "Point.PointN dimension"
instance Num a => Num (PointN a) where
(+) = (<+>)
() = (<->)
negate = negateP
(*) = undefined
abs = fmap abs
signum = undefined
fromInteger = undefined