static-tensor- Tensors of statically known size

Copyright(C) 2017 Alexey Vagarenko
LicenseBSD-style (see LICENSE)
MaintainerAlexey Vagarenko (
Safe HaskellNone






Vector types

type Vector n e = Tensor '[n] e Source #

N-dimensional vector.

type VectorConstructor n e = TensorConstructor '[n] e Source #

Type of vector data constructor.

type IsVector n e = IsTensor '[n] e Source #

Vector constraint.


vector :: forall n e. IsVector n e => VectorConstructor n e Source #

Alias for a conrete vector data constructor.

Vector Operations

normalize :: Normalize n e => Vector n e -> NormalizedVector n e Source #

Normalize vector.

data NormalizedVector n e Source #

Normalized vector.


Eq (Vector n e) => Eq (NormalizedVector n e) Source # 
Show (Vector n e) => Show (NormalizedVector n e) Source # 
Generic (NormalizedVector n e) Source # 

Associated Types

type Rep (NormalizedVector n e) :: * -> * #

type Rep (NormalizedVector n e) Source # 
type Rep (NormalizedVector n e) = D1 * (MetaData "NormalizedVector" "Data.Vector.Static" "static-tensor-" True) (C1 * (MetaCons "NormalizedVector" PrefixI True) (S1 * (MetaSel (Just Symbol "unNormalizedVector") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Vector n e))))

type Normalize (n :: Nat) e = (VectorLen n e, Scale '[n] e) Source #

Constraints for normalize function.

unNormalizedVector :: NormalizedVector n e -> Vector n e Source #

unwrap NormalizedVector. Note: this does not give you original vector back.

unNormalizedVector . normalize /= id

vectorLenSquare :: VectorLenSquare n e => Vector n e -> e Source #

Get square of length of a vector.

type VectorLenSquare (n :: Nat) e = (Num e, IsVector n e, MonoFunctorCtx '[n] e, MonoFoldableCtx '[n] e) Source #

Constraints for vectorLenSquare function.

vectorLen :: VectorLen n e => Vector n e -> e Source #

Get length of a vector.

type VectorLen (n :: Nat) e = (Floating e, VectorLenSquare n e) Source #

Constraints for vectorLen function.

dot :: Dot n e => Vector n e -> Vector n e -> e Source #

Dot product of two vectors.

type Dot (n :: Nat) e = (Num e, IsVector n e, MonoFunctorCtx '[n] e, MonoFoldableCtx '[n] e, MonoZipCtx '[n] e) Source #

Constraints for dot function.

cross :: (Num e, IsVector 3 e) => Vector 3 e -> Vector 3 e -> Vector 3 e Source #

Cross product is only defined for 3-dimensional vectors.

Generating vector instances

genVectorInstance Source #


:: Int

Size of the vector.

-> Name

Type of elements.

-> Q [Dec] 

Generate instance of a vector.