Copyright | (c) Scott N. Walck 2011-2019 |
---|---|
License | BSD3 (see LICENSE) |
Maintainer | Scott N. Walck <walck@lvc.edu> |
Stability | experimental |
Safe Haskell | Safe |
Language | Haskell2010 |
This module defines some basic vector functionality.
It uses the same internal data representation as SimpleVec
,
but declares Vec
to be an instance of VectorSpace
.
We import zeroV
, negateV
, sumV
, ^+^
, ^-^
from AdditiveGroup
, and
*^
, ^*
, ^/
, <.>
, magnitude
from VectorSpace
.
CarrotVec
exports exactly the same symbols as SimpleVec
;
they are just defined differently.
Synopsis
- data Vec
- type R = Double
- xComp :: Vec -> R
- yComp :: Vec -> R
- zComp :: Vec -> R
- vec :: R -> R -> R -> Vec
- (^+^) :: AdditiveGroup v => v -> v -> v
- (^-^) :: AdditiveGroup v => v -> v -> v
- (*^) :: VectorSpace v => Scalar v -> v -> v
- (^*) :: (VectorSpace v, s ~ Scalar v) => v -> s -> v
- (^/) :: (VectorSpace v, s ~ Scalar v, Fractional s) => v -> s -> v
- (<.>) :: InnerSpace v => v -> v -> Scalar v
- (><) :: Vec -> Vec -> Vec
- magnitude :: (InnerSpace v, s ~ Scalar v, Floating s) => v -> s
- zeroV :: AdditiveGroup v => v
- negateV :: AdditiveGroup v => v -> v
- sumV :: (Foldable f, AdditiveGroup v) => f v -> v
- iHat :: Vec
- jHat :: Vec
- kHat :: Vec
Documentation
A type for vectors.
Form a vector by giving its x, y, and z components.
(^+^) :: AdditiveGroup v => v -> v -> v infixl 6 #
Add vectors
(^-^) :: AdditiveGroup v => v -> v -> v infixl 6 #
Group subtraction
(*^) :: VectorSpace v => Scalar v -> v -> v infixr 7 #
Scale a vector
(^*) :: (VectorSpace v, s ~ Scalar v) => v -> s -> v infixl 7 #
Vector multiplied by scalar
(^/) :: (VectorSpace v, s ~ Scalar v, Fractional s) => v -> s -> v infixr 7 #
Vector divided by scalar
(<.>) :: InnerSpace v => v -> v -> Scalar v infixr 7 #
Inner/dot product
magnitude :: (InnerSpace v, s ~ Scalar v, Floating s) => v -> s #
Length of a vector. See also magnitudeSq
.
zeroV :: AdditiveGroup v => v #
The zero element: identity for (^+^)
negateV :: AdditiveGroup v => v -> v #
Additive inverse
sumV :: (Foldable f, AdditiveGroup v) => f v -> v #
Sum over several vectors