tensor-0.1: A completely type-safe library for linear algebra

Data.Tensor

Synopsis

# Documentation

class Tensor t whereSource

A `Tensor` is a map from an `Index` type (which should be a `MultiIndex`) to an `Elem`ent type.

Associated Types

type Index t Source

type Elem t Source

Methods

dims :: t -> Index tSource

`dims` returns the dimensions of the `Tensor`. In any instance of `Tensor` `dims` should be independent of its argument and work on `undefined`.

(!) :: t -> Index t -> Elem tSource

Returns the `Elem`ent of `t` corresponding to `Index t`.

generate :: (Index t -> Elem t) -> tSource

Generates a `Tensor` according to the given function.

replicate :: Elem t -> tSource

Generates a `Tensor` consisting of the same `Elem`ent repeated.

Instances

 (Bounded i, MultiIndex i) => Tensor (Tensor i e)

class FromList t whereSource

Methods

fromList :: [e] -> t eSource

Instances

 (Bounded i, Cardinality i, MultiIndex i) => FromList (Tensor i)

class DirectSum n t1 t2 whereSource

Associated Types

type SumSpace n t1 t2 Source

Methods

directSum :: n -> t1 -> t2 -> SumSpace n t1 t2Source

Instances

 (Cardinal n, MultiIndex i, MultiIndex j, MultiIndexConcat n i j) => DirectSum n (Tensor i e) (Tensor j e)

class Transpose t whereSource

Associated Types

type TransposeSpace t Source

Instances

 (Ordinal i, Ordinal j) => Transpose (Tensor (:|: i (:|: j Nil)) e)

class Zip t whereSource

Methods

zipWith :: (a -> b -> c) -> t a -> t b -> t cSource

Instances

 Zip (Tensor i)