taco-0.1.0.0: Haskell port of the Tensor Algebra COmpiler

Safe HaskellNone
LanguageHaskell2010

Data.Tensor

Contents

Synopsis

Tensor type

data Tensor i a where Source #

The Tensor type. Tensor data entries are stored as one single array

Constructors

T :: Sh i -> Vector a -> Tensor (Sh i) a 

Instances

Functor (Tensor i) Source # 

Methods

fmap :: (a -> b) -> Tensor i a -> Tensor i b #

(<$) :: a -> Tensor i b -> Tensor i a #

Eq a => Eq (Tensor i a) Source # 

Methods

(==) :: Tensor i a -> Tensor i a -> Bool #

(/=) :: Tensor i a -> Tensor i a -> Bool #

Show a => Show (Tensor i a) Source # 

Methods

showsPrec :: Int -> Tensor i a -> ShowS #

show :: Tensor i a -> String #

showList :: [Tensor i a] -> ShowS #

shape :: Tensor sh a -> sh Source #

Access the shape of a tensor

nnz :: Tensor i a -> Int Source #

Number of nonzero tensor elements

Shape type

data Sh sh where Source #

A statically-typed tensor shape parameter that supports both sparse and dense dimensions. Dimensions are indexed with Int32 indices, which should be enough for most applications.

Constructors

Z :: Sh Z 
D :: Sh sh -> Dd Int32 -> Sh (sh :# Int32)

Constructor for a dense dimension

S :: Sh sh -> Sd Int32 -> Sh (sh :. Int32)

Constructor for a sparse dimension

Instances

Eq (Sh sh) Source # 

Methods

(==) :: Sh sh -> Sh sh -> Bool #

(/=) :: Sh sh -> Sh sh -> Bool #

Show (Sh sh) Source # 

Methods

showsPrec :: Int -> Sh sh -> ShowS #

show :: Sh sh -> String #

showList :: [Sh sh] -> ShowS #

Dimension types

newtype Dd i Source #

To define a dense dimension we only need the dimensionality parameter

Constructors

Dd 

Fields

Instances

Eq i => Eq (Dd i) Source # 

Methods

(==) :: Dd i -> Dd i -> Bool #

(/=) :: Dd i -> Dd i -> Bool #

Show i => Show (Dd i) Source # 

Methods

showsPrec :: Int -> Dd i -> ShowS #

show :: Dd i -> String #

showList :: [Dd i] -> ShowS #

data Sd i Source #

To define a sparse dimension we need a cumulative array, an index array and a dimensionality parameter

Constructors

Sd 

Fields

Instances

(Eq i, Unbox i) => Eq (Sd i) Source # 

Methods

(==) :: Sd i -> Sd i -> Bool #

(/=) :: Sd i -> Sd i -> Bool #

(Unbox i, Show i) => Show (Sd i) Source # 

Methods

showsPrec :: Int -> Sd i -> ShowS #

show :: Sd i -> String #

showList :: [Sd i] -> ShowS #