sparse-tensor-0.2.1.2: typesafe tensor algebra library

Copyright (c) 2019 Tobias Reinhart and Nils Alex MIT tobi.reinhart@fau.de, nils.alex@fau.de None Haskell2010

Math.Tensor

Description

This module defines the basic data types and functions of the sparse-tensor package.

The Tensor n k v data type provides the fundamental building block of all further tensor types. It represents a general tensor that takes n individual indices all belonging to the same index typ k and retrieves values of type v. As such the Tensor type can be thought of representing a single tensor that only features contravariant indices.

Tensor n k v is internally implemented as an ordered forest with nodes of type k and leafs of type v.

Additional covariant indices can be incorporated by adjoining leafs of type Tensor n2 k v to a Tensor n1 k v. This yields the type Tensor2 n1 n2 k v which thus is used to represent the tensors in the traditional sense that include contravariant and covariant indices of the same type, i.e. running over the same index range.

Recursively appending further Tensors as leafs each one with possibly different index types and different ranks allows the sparse-tensor package cover the treatment of more complicated tensors with an arbitrary number of different indices.

The Tensor data type directly incorporates its rank in form of a type level natural number n. This results in added type safety when performing the usual tensor algebra operations. To provide a simple example the addition of two tensors is only meaningful if the ranks of the two tensors coincide. Hence then sparse-tensor package only incorporates an addition of Tensors with the same type. Unintentional additions of Tensors with different type then immediately yields a type error thus preventing the mistake.

Furthermore the Tensor type employs a sparse storage paradigm in the sense that when constructing Tensors only non zero values must be specified. Missing values are then taken as vanishing automatically.

Synopsis

# Tensor Data Types

## Length Typed Index List

Tensors provide information regarding their number of indices, i.e. their rank in their type. Consequently when constructing them from lists of indices value pairs and converting them to such it is advantageous when also these lists contain the additional length information in their type.

data IndList n a where Source #

Constructors

 Empty :: IndList 0 a Append :: a -> IndList (n - 1) a -> IndList n a
Instances
 Source # Instance detailsDefined in Math.Tensor Methodsfmap :: (a -> b) -> IndList n a -> IndList n b #(<$) :: a -> IndList n b -> IndList n a # Source # Instance detailsDefined in Math.Tensor Methodsfold :: Monoid m => IndList n m -> m #foldMap :: Monoid m => (a -> m) -> IndList n a -> m #foldr :: (a -> b -> b) -> b -> IndList n a -> b #foldr' :: (a -> b -> b) -> b -> IndList n a -> b #foldl :: (b -> a -> b) -> b -> IndList n a -> b #foldl' :: (b -> a -> b) -> b -> IndList n a -> b #foldr1 :: (a -> a -> a) -> IndList n a -> a #foldl1 :: (a -> a -> a) -> IndList n a -> a #toList :: IndList n a -> [a] #null :: IndList n a -> Bool #length :: IndList n a -> Int #elem :: Eq a => a -> IndList n a -> Bool #maximum :: Ord a => IndList n a -> a #minimum :: Ord a => IndList n a -> a #sum :: Num a => IndList n a -> a #product :: Num a => IndList n a -> a # Eq a => Eq (IndList n a) Source # Instance detailsDefined in Math.Tensor Methods(==) :: IndList n a -> IndList n a -> Bool #(/=) :: IndList n a -> IndList n a -> Bool # Ord a => Ord (IndList n a) Source # Instance detailsDefined in Math.Tensor Methodscompare :: IndList n a -> IndList n a -> Ordering #(<) :: IndList n a -> IndList n a -> Bool #(<=) :: IndList n a -> IndList n a -> Bool #(>) :: IndList n a -> IndList n a -> Bool #(>=) :: IndList n a -> IndList n a -> Bool #max :: IndList n a -> IndList n a -> IndList n a #min :: IndList n a -> IndList n a -> IndList n a # Show a => Show (IndList n a) Source # Instance detailsDefined in Math.Tensor MethodsshowsPrec :: Int -> IndList n a -> ShowS #show :: IndList n a -> String #showList :: [IndList n a] -> ShowS # (KnownNat n, Generic a) => Generic (IndList n a) Source # Instance detailsDefined in Math.Tensor Associated Typestype Rep (IndList n a) :: Type -> Type # Methodsfrom :: IndList n a -> Rep (IndList n a) x #to :: Rep (IndList n a) x -> IndList n a # (KnownNat n, Generic a, Serialize a) => Serialize (IndList n a) Source # Instance detailsDefined in Math.Tensor Methodsput :: Putter (IndList n a) #get :: Get (IndList n a) # NFData a => NFData (IndList n a) Source # Instance detailsDefined in Math.Tensor Methodsrnf :: IndList n a -> () # type Rep (IndList n a) Source # Instance detailsDefined in Math.Tensor type Rep (IndList n a) = Rep [a] singletonInd :: a -> IndList 1 a Source # Construct an IndList that only contains a single value. (+>) :: Enum a => Int -> IndList (n - 1) a -> IndList n a infixr 5 Source # Infix synonym for Append. fromList :: forall n. KnownNat n => forall (a :: *). [a] -> Maybe (IndList n a) Source # Construction of a length typed IndList from an untyped list. fromListUnsafe :: forall n. KnownNat n => forall (a :: *). [a] -> IndList n a Source # Construction of a length typed IndList (partial function). headInd :: IndList n a -> a Source # An implementation of the usual head function from Data.List for IndLists. The function returns the first element of the IndList. tailInd :: IndList n a -> IndList (n - 1) a Source # An implementation of the usual tail function from Data.List for IndLists. The function removes the first element of the IndList. sortInd :: (Ord a, Eq a) => IndList n a -> IndList n a Source # Sorts an IndList of elements that satisfy the Ord constraint by implementing a version of insertion sort. updateInd :: Int -> a -> IndList n a -> IndList n a Source # The function replaces the element at index/position specified by its first argument with the element that is specified by its second argument. ## The Tensor Type The basic tensor type Tensor n k v represents a tensor that takes n indices of type k and maps them to values of type v. This type can be thought of as representing a single, purely contravariant tensor that features n indices. A general abstract tensor with multiple possibly different indices is obtained by simply adjoining the appropriate number of individual basic tensors. The Tensor type is internally implemented as ordered forest with nodes being the individual indices and leafs given by the corresponding values. type TMap k v = [(k, v)] Source # Additional type for the sorted tensor forest. TMap k v represents an ordered list of key value pairs. Ordering is always defined w.r.t. the keys. All future functions maintain this order when acting on a valid, i.e. ordered TMaps. data Tensor n k v where Source # Constructors  Scalar :: v -> Tensor 0 k v Constructor of leaf values. Tensor :: TMap k (Tensor n k v) -> Tensor (n + 1) k v Constructs a Tensor from a TMap of index sub tensor pairs. ZeroTensor :: Tensor n k v Represents a Tensor that is identical zero. Instances  (TIndex k, Prod SSymbolic v) => Prod SSymbolic (Tensor n k v) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd SSymbolic (Tensor n k v) :: Type Source # Methodsprod :: SSymbolic -> Tensor n k v -> TProd SSymbolic (Tensor n k v) Source # (TIndex k, Prod (AnsVar s) v) => Prod (AnsVar s) (Tensor n k v) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (AnsVar s) (Tensor n k v) :: Type Source # Methodsprod :: AnsVar s -> Tensor n k v -> TProd (AnsVar s) (Tensor n k v) Source # (TIndex k, Prod (SField s) v) => Prod (SField s) (Tensor n k v) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (SField s) (Tensor n k v) :: Type Source # Methodsprod :: SField s -> Tensor n k v -> TProd (SField s) (Tensor n k v) Source # Functor (Tensor n k) Source # Instance detailsDefined in Math.Tensor Methodsfmap :: (a -> b) -> Tensor n k a -> Tensor n k b #(<$) :: a -> Tensor n k b -> Tensor n k a # (Eq a, Eq k) => Eq (Tensor n k a) Source # Instance detailsDefined in Math.Tensor Methods(==) :: Tensor n k a -> Tensor n k a -> Bool #(/=) :: Tensor n k a -> Tensor n k a -> Bool # (Show a, Show k) => Show (Tensor n k a) Source # Instance detailsDefined in Math.Tensor MethodsshowsPrec :: Int -> Tensor n k a -> ShowS #show :: Tensor n k a -> String #showList :: [Tensor n k a] -> ShowS # KnownNat n => Generic (Tensor n k v) Source # Instance detailsDefined in Math.Tensor Associated Typestype Rep (Tensor n k v) :: Type -> Type # Methodsfrom :: Tensor n k v -> Rep (Tensor n k v) x #to :: Rep (Tensor n k v) x -> Tensor n k v # (KnownNat n, Ord k, Serialize k, Serialize v) => Serialize (Tensor n k v) Source # Instance detailsDefined in Math.Tensor Methodsput :: Putter (Tensor n k v) #get :: Get (Tensor n k v) # (NFData k, NFData v) => NFData (Tensor n k v) Source # Instance detailsDefined in Math.Tensor Methodsrnf :: Tensor n k v -> () # (TIndex k, TAdd v) => TAdd (Tensor n k v) Source # Instance detailsDefined in Math.Tensor MethodsscaleZero :: Tensor n k v -> Bool Source #addS :: Tensor n k v -> Tensor n k v -> Tensor n k v Source #negateS :: Tensor n k v -> Tensor n k v Source #subS :: Tensor n k v -> Tensor n k v -> Tensor n k v Source # (TIndex k, Prod v v') => Prod (Tensor n k v) (Tensor n' k v') Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (Tensor n k v) (Tensor n' k v') :: Type Source # Methodsprod :: Tensor n k v -> Tensor n' k v' -> TProd (Tensor n k v) (Tensor n' k v') Source # type TProd SSymbolic (Tensor n k v) Source # Instance detailsDefined in Math.Tensor type TProd SSymbolic (Tensor n k v) = Tensor n k (TProd SSymbolic v) type TProd (AnsVar s) (Tensor n k v) Source # Instance detailsDefined in Math.Tensor type TProd (AnsVar s) (Tensor n k v) = Tensor n k (TProd (AnsVar s) v) type TProd (SField s) (Tensor n k v) Source # Instance detailsDefined in Math.Tensor type TProd (SField s) (Tensor n k v) = Tensor n k (TProd (SField s) v) type Rep (Tensor n k v) Source # Instance detailsDefined in Math.Tensor type Rep (Tensor n k v) type TProd (Tensor n k v) (Tensor n' k v') Source # Instance detailsDefined in Math.Tensor type TProd (Tensor n k v) (Tensor n' k v') = Tensor (n + n') k (TProd v v')

type Tensor2 n1 n2 k v = Tensor n1 k (Tensor n2 k v) Source #

Represents a Tensor with attached Scalars being again of Tensor type and taking the same index type. This type can be used to represent a general Tensor that takes contravariant and covariant indices.

The following types are synonyms that are used to represent tensors with multiple different indices. For instance AbsTensor4 can be used to represent any tensor that features two different index types with different index ranges that both appear in contravariant and covariant position.

type AbsTensor1 n1 k1 v = Tensor n1 k1 v Source #

type AbsTensor2 n1 n2 k1 v = Tensor2 n1 n2 k1 v Source #

type AbsTensor3 n1 n2 n3 k1 k2 v = AbsTensor2 n1 n2 k1 (Tensor n3 k2 v) Source #

type AbsTensor4 n1 n2 n3 n4 k1 k2 v = AbsTensor2 n1 n2 k1 (Tensor2 n3 n4 k2 v) Source #

type AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v = AbsTensor4 n1 n2 n3 n4 k1 k2 (Tensor n5 k3 v) Source #

type AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v = AbsTensor4 n1 n2 n3 n4 k1 k2 (Tensor2 n5 n6 k3 v) Source #

type AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v = AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (Tensor n7 k4 v) Source #

type AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v = AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (Tensor2 n7 n8 k4 v) Source #

type STTens n1 n2 v = AbsTensor2 n1 n2 Ind3 v Source #

Type synonym for a Tensor with contravariant and covariant spacetime indices.

type ATens n1 n2 n3 n4 n5 n6 v = AbsTensor6 n1 n2 n3 n4 n5 n6 Ind20 Ind9 Ind3 v Source #

Type synonym for a Tensor with three different index types ranging from 0 to 20, from 0 to 9 and from 0 to 3 each one appearing contravariantly and covariantly.

## Index Type Class

class (Eq a, Ord a, Enum a) => TIndex a Source #

The TIndex type class collects a number of class constraints that any index type must satisfy.

Instances
 Source # Instance detailsDefined in Math.Tensor Source # Instance detailsDefined in Math.Tensor Source # Instance detailsDefined in Math.Tensor

newtype Ind3 Source #

Newtype wrapper for an index type that is used to represent indices with a range from 0 to 3.

Constructors

 Ind3 FieldsindVal3 :: Int
Instances
 Source # Instance detailsDefined in Math.Tensor Methodssucc :: Ind3 -> Ind3 #pred :: Ind3 -> Ind3 #toEnum :: Int -> Ind3 #fromEnum :: Ind3 -> Int #enumFrom :: Ind3 -> [Ind3] #enumFromThen :: Ind3 -> Ind3 -> [Ind3] #enumFromTo :: Ind3 -> Ind3 -> [Ind3] #enumFromThenTo :: Ind3 -> Ind3 -> Ind3 -> [Ind3] # Source # Instance detailsDefined in Math.Tensor Methods(==) :: Ind3 -> Ind3 -> Bool #(/=) :: Ind3 -> Ind3 -> Bool # Source # Instance detailsDefined in Math.Tensor Methodscompare :: Ind3 -> Ind3 -> Ordering #(<) :: Ind3 -> Ind3 -> Bool #(<=) :: Ind3 -> Ind3 -> Bool #(>) :: Ind3 -> Ind3 -> Bool #(>=) :: Ind3 -> Ind3 -> Bool #max :: Ind3 -> Ind3 -> Ind3 #min :: Ind3 -> Ind3 -> Ind3 # Source # Instance detailsDefined in Math.Tensor Methods Source # Instance detailsDefined in Math.Tensor MethodsshowsPrec :: Int -> Ind3 -> ShowS #show :: Ind3 -> String #showList :: [Ind3] -> ShowS # Source # Instance detailsDefined in Math.Tensor Associated Typestype Rep Ind3 :: Type -> Type # Methodsfrom :: Ind3 -> Rep Ind3 x #to :: Rep Ind3 x -> Ind3 # Source # Instance detailsDefined in Math.Tensor Methods Source # Instance detailsDefined in Math.Tensor Methodsrnf :: Ind3 -> () # Source # Instance detailsDefined in Math.Tensor type Rep Ind3 Source # Instance detailsDefined in Math.Tensor type Rep Ind3 = D1 (MetaData "Ind3" "Math.Tensor" "sparse-tensor-0.2.1.2-5t3AWNPJ0YtAucphGlrflx" True) (C1 (MetaCons "Ind3" PrefixI True) (S1 (MetaSel (Just "indVal3") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)))

newtype Ind9 Source #

Newtype wrapper for an index type that is used to represent indices with a range from 0 to 9.

Constructors

 Ind9 FieldsindVal9 :: Int
Instances
 Source # Instance detailsDefined in Math.Tensor Methodssucc :: Ind9 -> Ind9 #pred :: Ind9 -> Ind9 #toEnum :: Int -> Ind9 #fromEnum :: Ind9 -> Int #enumFrom :: Ind9 -> [Ind9] #enumFromThen :: Ind9 -> Ind9 -> [Ind9] #enumFromTo :: Ind9 -> Ind9 -> [Ind9] #enumFromThenTo :: Ind9 -> Ind9 -> Ind9 -> [Ind9] # Source # Instance detailsDefined in Math.Tensor Methods(==) :: Ind9 -> Ind9 -> Bool #(/=) :: Ind9 -> Ind9 -> Bool # Source # Instance detailsDefined in Math.Tensor Methodscompare :: Ind9 -> Ind9 -> Ordering #(<) :: Ind9 -> Ind9 -> Bool #(<=) :: Ind9 -> Ind9 -> Bool #(>) :: Ind9 -> Ind9 -> Bool #(>=) :: Ind9 -> Ind9 -> Bool #max :: Ind9 -> Ind9 -> Ind9 #min :: Ind9 -> Ind9 -> Ind9 # Source # Instance detailsDefined in Math.Tensor Methods Source # Instance detailsDefined in Math.Tensor MethodsshowsPrec :: Int -> Ind9 -> ShowS #show :: Ind9 -> String #showList :: [Ind9] -> ShowS # Source # Instance detailsDefined in Math.Tensor Associated Typestype Rep Ind9 :: Type -> Type # Methodsfrom :: Ind9 -> Rep Ind9 x #to :: Rep Ind9 x -> Ind9 # Source # Instance detailsDefined in Math.Tensor Methods Source # Instance detailsDefined in Math.Tensor Methodsrnf :: Ind9 -> () # Source # Instance detailsDefined in Math.Tensor type Rep Ind9 Source # Instance detailsDefined in Math.Tensor type Rep Ind9 = D1 (MetaData "Ind9" "Math.Tensor" "sparse-tensor-0.2.1.2-5t3AWNPJ0YtAucphGlrflx" True) (C1 (MetaCons "Ind9" PrefixI True) (S1 (MetaSel (Just "indVal9") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)))

newtype Ind20 Source #

Newtype wrapper for an index type that is used to represent indices with a from 0 to 20.

Constructors

 Ind20 FieldsindVal20 :: Int
Instances
 Source # Instance detailsDefined in Math.Tensor Methodssucc :: Ind20 -> Ind20 #pred :: Ind20 -> Ind20 #toEnum :: Int -> Ind20 #enumFrom :: Ind20 -> [Ind20] #enumFromThen :: Ind20 -> Ind20 -> [Ind20] #enumFromTo :: Ind20 -> Ind20 -> [Ind20] #enumFromThenTo :: Ind20 -> Ind20 -> Ind20 -> [Ind20] # Source # Instance detailsDefined in Math.Tensor Methods(==) :: Ind20 -> Ind20 -> Bool #(/=) :: Ind20 -> Ind20 -> Bool # Source # Instance detailsDefined in Math.Tensor Methods(<) :: Ind20 -> Ind20 -> Bool #(<=) :: Ind20 -> Ind20 -> Bool #(>) :: Ind20 -> Ind20 -> Bool #(>=) :: Ind20 -> Ind20 -> Bool #max :: Ind20 -> Ind20 -> Ind20 #min :: Ind20 -> Ind20 -> Ind20 # Source # Instance detailsDefined in Math.Tensor Methods Source # Instance detailsDefined in Math.Tensor MethodsshowsPrec :: Int -> Ind20 -> ShowS #show :: Ind20 -> String #showList :: [Ind20] -> ShowS # Source # Instance detailsDefined in Math.Tensor Associated Typestype Rep Ind20 :: Type -> Type # Methodsfrom :: Ind20 -> Rep Ind20 x #to :: Rep Ind20 x -> Ind20 # Source # Instance detailsDefined in Math.Tensor Methods Source # Instance detailsDefined in Math.Tensor Methodsrnf :: Ind20 -> () # Source # Instance detailsDefined in Math.Tensor type Rep Ind20 Source # Instance detailsDefined in Math.Tensor type Rep Ind20 = D1 (MetaData "Ind20" "Math.Tensor" "sparse-tensor-0.2.1.2-5t3AWNPJ0YtAucphGlrflx" True) (C1 (MetaCons "Ind20" PrefixI True) (S1 (MetaSel (Just "indVal20") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)))

## Tensor Value Type Class

Types that any Tensor might use as values must satisfy number like properties, more precisely they must constitute an additive group. This requirement is encoded in the TAdd type class.

Allowing further for the computation of tensor products the Tensor types resemble the structure of the usual graded tensor algebra on the type level. When computing tensor products of different ranked tensors and also tensors with different value type it is thus necessary that the two Tensor types provide the information regarding the explicit type of their product. This is the case if the two value types provide an instance of the Prod type class.

If the values of a given tensor are instances of these two type classes also tensor type Tensor itself represents an instance of them. This allows the use of the basic tensor algebra functions and also many further tensor functions irrespective of the values of a given Tensor are themselves Tensors or represent simple scalar values.

class TAdd a where Source #

Type class that encodes the additive group structure of possible Tensor values, i.e. addition, neutral element and existence of inverse elements. Each possible Tensor value must allow for these basic group operations and hence be an instance of this type class.

Minimal complete definition

Methods

scaleZero :: a -> Bool Source #

Test whether the given element is zero, i.e. the neutral element.

addS :: a -> a -> a Source #

Addition of two elements.

negateS :: a -> a Source #

Maps an element to its additive inverse.

subS :: a -> a -> a Source #

Subtraction of two elements.

Instances
 Source # Instance detailsDefined in Math.Tensor Methods TAdd a => TAdd (AnsVar a) Source # Instance detailsDefined in Math.Tensor MethodsaddS :: AnsVar a -> AnsVar a -> AnsVar a Source #negateS :: AnsVar a -> AnsVar a Source #subS :: AnsVar a -> AnsVar a -> AnsVar a Source # (Num a, Eq a) => TAdd (SField a) Source # Instance detailsDefined in Math.Tensor MethodsaddS :: SField a -> SField a -> SField a Source #negateS :: SField a -> SField a Source #subS :: SField a -> SField a -> SField a Source # Num b => TAdd (CFun a b) Source # Instance detailsDefined in Math.Tensor MethodsscaleZero :: CFun a b -> Bool Source #addS :: CFun a b -> CFun a b -> CFun a b Source #negateS :: CFun a b -> CFun a b Source #subS :: CFun a b -> CFun a b -> CFun a b Source # (TIndex k, TAdd v) => TAdd (Tensor n k v) Source # Instance detailsDefined in Math.Tensor MethodsscaleZero :: Tensor n k v -> Bool Source #addS :: Tensor n k v -> Tensor n k v -> Tensor n k v Source #negateS :: Tensor n k v -> Tensor n k v Source #subS :: Tensor n k v -> Tensor n k v -> Tensor n k v Source #

class Prod v v' where Source #

Type class for product of two (possibly different) types. The resulting type depends on the types that are given as input.

Associated Types

type TProd v v' :: * Source #

Type level function that returns the type of the result of prod.

Methods

prod :: v -> v' -> TProd v v' Source #

Product function.

Instances
 Source # Instance detailsDefined in Math.Tensor Associated Types Methods Show a => Prod SSymbolic (SField a) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd SSymbolic (SField a) :: Type Source # Methods (TIndex k, Prod SSymbolic v) => Prod SSymbolic (Tensor n k v) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd SSymbolic (Tensor n k v) :: Type Source # Methodsprod :: SSymbolic -> Tensor n k v -> TProd SSymbolic (Tensor n k v) Source # Show a => Prod (SField a) SSymbolic Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (SField a) SSymbolic :: Type Source # Methods Prod (SField v') (SField v) => Prod (AnsVar (SField v)) (SField v') Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (AnsVar (SField v)) (SField v') :: Type Source # Methodsprod :: AnsVar (SField v) -> SField v' -> TProd (AnsVar (SField v)) (SField v') Source # Prod (SField v) (SField v') => Prod (SField v) (AnsVar (SField v')) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (SField v) (AnsVar (SField v')) :: Type Source # Methodsprod :: SField v -> AnsVar (SField v') -> TProd (SField v) (AnsVar (SField v')) Source # Num a => Prod (SField a) (SField a) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (SField a) (SField a) :: Type Source # Methodsprod :: SField a -> SField a -> TProd (SField a) (SField a) Source # Num b => Prod (SField b) (CFun a b) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (SField b) (CFun a b) :: Type Source # Methodsprod :: SField b -> CFun a b -> TProd (SField b) (CFun a b) Source # (TIndex k, Prod (AnsVar s) v) => Prod (AnsVar s) (Tensor n k v) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (AnsVar s) (Tensor n k v) :: Type Source # Methodsprod :: AnsVar s -> Tensor n k v -> TProd (AnsVar s) (Tensor n k v) Source # (TIndex k, Prod (SField s) v) => Prod (SField s) (Tensor n k v) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (SField s) (Tensor n k v) :: Type Source # Methodsprod :: SField s -> Tensor n k v -> TProd (SField s) (Tensor n k v) Source # Num b => Prod (CFun a b) (CFun a b) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (CFun a b) (CFun a b) :: Type Source # Methodsprod :: CFun a b -> CFun a b -> TProd (CFun a b) (CFun a b) Source # (TIndex k, Prod v v') => Prod (Tensor n k v) (Tensor n' k v') Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (Tensor n k v) (Tensor n' k v') :: Type Source # Methodsprod :: Tensor n k v -> Tensor n' k v' -> TProd (Tensor n k v) (Tensor n' k v') Source #

## Tensor Value Instances

### Scalar Values

newtype SField a Source #

Newtype wrapper that is used for representing scalar values.

Constructors

 SField a
Instances
 Source # Instance detailsDefined in Math.Tensor Methodsfmap :: (a -> b) -> SField a -> SField b #(<$) :: a -> SField b -> SField a # Source # Instance detailsDefined in Math.Tensor Methodspure :: a -> SField a #(<*>) :: SField (a -> b) -> SField a -> SField b #liftA2 :: (a -> b -> c) -> SField a -> SField b -> SField c #(*>) :: SField a -> SField b -> SField b #(<*) :: SField a -> SField b -> SField a # Show a => Prod SSymbolic (SField a) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd SSymbolic (SField a) :: Type Source # Methods Eq a => Eq (SField a) Source # Instance detailsDefined in Math.Tensor Methods(==) :: SField a -> SField a -> Bool #(/=) :: SField a -> SField a -> Bool # Num a => Num (SField a) Source # Instance detailsDefined in Math.Tensor Methods(+) :: SField a -> SField a -> SField a #(-) :: SField a -> SField a -> SField a #(*) :: SField a -> SField a -> SField a #negate :: SField a -> SField a #abs :: SField a -> SField a #signum :: SField a -> SField a # Ord a => Ord (SField a) Source # Instance detailsDefined in Math.Tensor Methodscompare :: SField a -> SField a -> Ordering #(<) :: SField a -> SField a -> Bool #(<=) :: SField a -> SField a -> Bool #(>) :: SField a -> SField a -> Bool #(>=) :: SField a -> SField a -> Bool #max :: SField a -> SField a -> SField a #min :: SField a -> SField a -> SField a # Show a => Show (SField a) Source # Instance detailsDefined in Math.Tensor MethodsshowsPrec :: Int -> SField a -> ShowS #show :: SField a -> String #showList :: [SField a] -> ShowS # Source # Instance detailsDefined in Math.Tensor Associated Typestype Rep (SField a) :: Type -> Type # Methodsfrom :: SField a -> Rep (SField a) x #to :: Rep (SField a) x -> SField a # Serialize a => Serialize (SField a) Source # Instance detailsDefined in Math.Tensor Methodsput :: Putter (SField a) #get :: Get (SField a) # (Num a, Eq a) => TAdd (SField a) Source # Instance detailsDefined in Math.Tensor MethodsaddS :: SField a -> SField a -> SField a Source #negateS :: SField a -> SField a Source #subS :: SField a -> SField a -> SField a Source # Show a => Prod (SField a) SSymbolic Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (SField a) SSymbolic :: Type Source # Methods Prod (SField v') (SField v) => Prod (AnsVar (SField v)) (SField v') Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (AnsVar (SField v)) (SField v') :: Type Source # Methodsprod :: AnsVar (SField v) -> SField v' -> TProd (AnsVar (SField v)) (SField v') Source # Prod (SField v) (SField v') => Prod (SField v) (AnsVar (SField v')) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (SField v) (AnsVar (SField v')) :: Type Source # Methodsprod :: SField v -> AnsVar (SField v') -> TProd (SField v) (AnsVar (SField v')) Source # Num a => Prod (SField a) (SField a) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (SField a) (SField a) :: Type Source # Methodsprod :: SField a -> SField a -> TProd (SField a) (SField a) Source # Num b => Prod (SField b) (CFun a b) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (SField b) (CFun a b) :: Type Source # Methodsprod :: SField b -> CFun a b -> TProd (SField b) (CFun a b) Source # (TIndex k, Prod (SField s) v) => Prod (SField s) (Tensor n k v) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (SField s) (Tensor n k v) :: Type Source # Methodsprod :: SField s -> Tensor n k v -> TProd (SField s) (Tensor n k v) Source # type TProd SSymbolic (SField a) Source # Instance detailsDefined in Math.Tensor type TProd SSymbolic (SField a) = SSymbolic type Rep (SField a) Source # Instance detailsDefined in Math.Tensor type Rep (SField a) = D1 (MetaData "SField" "Math.Tensor" "sparse-tensor-0.2.1.2-5t3AWNPJ0YtAucphGlrflx" True) (C1 (MetaCons "SField" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a))) type TProd (SField a) SSymbolic Source # Instance detailsDefined in Math.Tensor type TProd (SField a) SSymbolic = SSymbolic type TProd (AnsVar (SField v)) (SField v') Source # Instance detailsDefined in Math.Tensor type TProd (AnsVar (SField v)) (SField v') = AnsVar (TProd (SField v') (SField v)) type TProd (SField a) (SField a) Source # Instance detailsDefined in Math.Tensor type TProd (SField a) (SField a) = SField a type TProd (SField v) (AnsVar (SField v')) Source # Instance detailsDefined in Math.Tensor type TProd (SField v) (AnsVar (SField v')) = AnsVar (TProd (SField v) (SField v')) type TProd (SField b) (CFun a b) Source # Instance detailsDefined in Math.Tensor type TProd (SField b) (CFun a b) = CFun a b type TProd (SField s) (Tensor n k v) Source # Instance detailsDefined in Math.Tensor type TProd (SField s) (Tensor n k v) = Tensor n k (TProd (SField s) v) ### Linear Variables newtype AnsVar a Source # The AnsVar a type represents a basic type for variables that must only occur linearly. As such they can for instance be used whenever tensorial expression involves a tensor with unknown components. This tensor can then be described as having values of type AnsVar. The AnsVar type can for instance be useful when the tensorial expression that involves the Tensor with AnsVar values describes a linear equation system. Using the functions toMatListT1, ... this equation system can then be transformed into a matrix with columns labeling the individual AnsVars. Constructors  AnsVar (IntMap a) Instances  Eq a => Eq (AnsVar a) Source # Instance detailsDefined in Math.Tensor Methods(==) :: AnsVar a -> AnsVar a -> Bool #(/=) :: AnsVar a -> AnsVar a -> Bool # Show a => Show (AnsVar a) Source # Instance detailsDefined in Math.Tensor MethodsshowsPrec :: Int -> AnsVar a -> ShowS #show :: AnsVar a -> String #showList :: [AnsVar a] -> ShowS # Source # Instance detailsDefined in Math.Tensor Associated Typestype Rep (AnsVar a) :: Type -> Type # Methodsfrom :: AnsVar a -> Rep (AnsVar a) x #to :: Rep (AnsVar a) x -> AnsVar a # Serialize a => Serialize (AnsVar a) Source # Instance detailsDefined in Math.Tensor Methodsput :: Putter (AnsVar a) #get :: Get (AnsVar a) # TAdd a => TAdd (AnsVar a) Source # Instance detailsDefined in Math.Tensor MethodsaddS :: AnsVar a -> AnsVar a -> AnsVar a Source #negateS :: AnsVar a -> AnsVar a Source #subS :: AnsVar a -> AnsVar a -> AnsVar a Source # Prod (SField v') (SField v) => Prod (AnsVar (SField v)) (SField v') Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (AnsVar (SField v)) (SField v') :: Type Source # Methodsprod :: AnsVar (SField v) -> SField v' -> TProd (AnsVar (SField v)) (SField v') Source # Prod (SField v) (SField v') => Prod (SField v) (AnsVar (SField v')) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (SField v) (AnsVar (SField v')) :: Type Source # Methodsprod :: SField v -> AnsVar (SField v') -> TProd (SField v) (AnsVar (SField v')) Source # (TIndex k, Prod (AnsVar s) v) => Prod (AnsVar s) (Tensor n k v) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (AnsVar s) (Tensor n k v) :: Type Source # Methodsprod :: AnsVar s -> Tensor n k v -> TProd (AnsVar s) (Tensor n k v) Source # type Rep (AnsVar a) Source # Instance detailsDefined in Math.Tensor type Rep (AnsVar a) = D1 (MetaData "AnsVar" "Math.Tensor" "sparse-tensor-0.2.1.2-5t3AWNPJ0YtAucphGlrflx" True) (C1 (MetaCons "AnsVar" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (IntMap a)))) type TProd (AnsVar (SField v)) (SField v') Source # Instance detailsDefined in Math.Tensor type TProd (AnsVar (SField v)) (SField v') = AnsVar (TProd (SField v') (SField v)) type TProd (SField v) (AnsVar (SField v')) Source # Instance detailsDefined in Math.Tensor type TProd (SField v) (AnsVar (SField v')) = AnsVar (TProd (SField v) (SField v')) type TProd (AnsVar s) (Tensor n k v) Source # Instance detailsDefined in Math.Tensor type TProd (AnsVar s) (Tensor n k v) = Tensor n k (TProd (AnsVar s) v) shiftVarLabels :: Int -> AnsVar a -> AnsVar a Source # Shifts the labels of the variables that are contained in the AnsVar type towards larger index labels by the amount specified. The following functions apply this shift of the variable labels, i.e. the function shiftVarLabels to all AnsVars that are contained in a Tensor. shiftLabels1 :: Int -> AbsTensor1 n1 k1 (AnsVar a) -> AbsTensor1 n1 k1 (AnsVar a) Source # shiftLabels1 s = mapTo1 (shiftVarLabels s) shiftLabels2 :: Int -> AbsTensor2 n1 n2 k1 (AnsVar a) -> AbsTensor2 n1 n2 k1 (AnsVar a) Source # shiftLabels2 s = mapTo2 (shiftVarLabels s) shiftLabels3 :: Int -> AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a) -> AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a) Source # shiftLabels3 s = mapTo3 (shiftVarLabels s) shiftLabels4 :: Int -> AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a) -> AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a) Source # shiftLabels4 s = mapTo4 (shiftVarLabels s) shiftLabels5 :: Int -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a) -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a) Source # shiftLabels5 s = mapTo5 (shiftVarLabels s) shiftLabels6 :: Int -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a) -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a) Source # shiftLabels6 s = mapTo6 (shiftVarLabels s) shiftLabels7 :: Int -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar a) -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar a) Source # shiftLabels7 s = mapTo7 (shiftVarLabels s) shiftLabels8 :: Int -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar a) -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar a) Source # shiftLabels8 s = mapTo8 (shiftVarLabels s) ### Functions as Values newtype CFun a b Source # Type for representation of functions as Tensor values. Constructors  CFun (a -> b) Instances  Functor (CFun a) Source # Instance detailsDefined in Math.Tensor Methodsfmap :: (a0 -> b) -> CFun a a0 -> CFun a b #(<$) :: a0 -> CFun a b -> CFun a a0 # Source # Instance detailsDefined in Math.Tensor Methodspure :: a0 -> CFun a a0 #(<*>) :: CFun a (a0 -> b) -> CFun a a0 -> CFun a b #liftA2 :: (a0 -> b -> c) -> CFun a a0 -> CFun a b -> CFun a c #(*>) :: CFun a a0 -> CFun a b -> CFun a b #(<*) :: CFun a a0 -> CFun a b -> CFun a a0 # Num b => Prod (SField b) (CFun a b) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (SField b) (CFun a b) :: Type Source # Methodsprod :: SField b -> CFun a b -> TProd (SField b) (CFun a b) Source # Num b => Num (CFun a b) Source # Instance detailsDefined in Math.Tensor Methods(+) :: CFun a b -> CFun a b -> CFun a b #(-) :: CFun a b -> CFun a b -> CFun a b #(*) :: CFun a b -> CFun a b -> CFun a b #negate :: CFun a b -> CFun a b #abs :: CFun a b -> CFun a b #signum :: CFun a b -> CFun a b #fromInteger :: Integer -> CFun a b # Num b => TAdd (CFun a b) Source # Instance detailsDefined in Math.Tensor MethodsscaleZero :: CFun a b -> Bool Source #addS :: CFun a b -> CFun a b -> CFun a b Source #negateS :: CFun a b -> CFun a b Source #subS :: CFun a b -> CFun a b -> CFun a b Source # Num b => Prod (CFun a b) (CFun a b) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (CFun a b) (CFun a b) :: Type Source # Methodsprod :: CFun a b -> CFun a b -> TProd (CFun a b) (CFun a b) Source # type TProd (SField b) (CFun a b) Source # Instance detailsDefined in Math.Tensor type TProd (SField b) (CFun a b) = CFun a b type TProd (CFun a b) (CFun a b) Source # Instance detailsDefined in Math.Tensor type TProd (CFun a b) (CFun a b) = CFun a b

evalSec :: (Num b, Eq b, Epsilon b) => STTens n1 n2 (CFun a b) -> a -> STTens n1 n2 (SField b) Source #

evaluate a tensor section, i.e. a CFun-valued STTens, at given spacetime point

### Symbolic Values

newtype SSymbolic Source #

Newtype wrapper for symbolic values. Note that this version does not yet support simplification of symbolic values.

Constructors

 SSymbolic String
Instances
 Source # Instance detailsDefined in Math.Tensor Methods Source # Instance detailsDefined in Math.Tensor Methods Source # Instance detailsDefined in Math.Tensor Methods Source # Instance detailsDefined in Math.Tensor MethodsshowList :: [SSymbolic] -> ShowS # Source # Instance detailsDefined in Math.Tensor Associated Typestype Rep SSymbolic :: Type -> Type # Methodsto :: Rep SSymbolic x -> SSymbolic # Source # Instance detailsDefined in Math.Tensor Methods Source # Instance detailsDefined in Math.Tensor Methods Source # Instance detailsDefined in Math.Tensor Associated Types Methods Show a => Prod SSymbolic (SField a) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd SSymbolic (SField a) :: Type Source # Methods (TIndex k, Prod SSymbolic v) => Prod SSymbolic (Tensor n k v) Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd SSymbolic (Tensor n k v) :: Type Source # Methodsprod :: SSymbolic -> Tensor n k v -> TProd SSymbolic (Tensor n k v) Source # Show a => Prod (SField a) SSymbolic Source # Instance detailsDefined in Math.Tensor Associated Typestype TProd (SField a) SSymbolic :: Type Source # Methods type Rep SSymbolic Source # Instance detailsDefined in Math.Tensor type Rep SSymbolic = D1 (MetaData "SSymbolic" "Math.Tensor" "sparse-tensor-0.2.1.2-5t3AWNPJ0YtAucphGlrflx" True) (C1 (MetaCons "SSymbolic" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String))) Source # Instance detailsDefined in Math.Tensor type TProd SSymbolic (SField a) Source # Instance detailsDefined in Math.Tensor type TProd SSymbolic (SField a) = SSymbolic type TProd SSymbolic (Tensor n k v) Source # Instance detailsDefined in Math.Tensor type TProd SSymbolic (Tensor n k v) = Tensor n k (TProd SSymbolic v) type TProd (SField a) SSymbolic Source # Instance detailsDefined in Math.Tensor type TProd (SField a) SSymbolic = SSymbolic

## Construction of Tensor

Tensors can most easily be constructed from key value list where the keys are tuples of either IndLists or simply traditional lists that encode the values of the various indices and the values then are the corresponding Tensor values. While the construction from tuples of normal lists is certainly more flexible it lacks the desired type safety that is incorporated when construction is achieved from tuples of length typed IndLists.

The following are type synonyms that are frequently for these key value lists.

type IndTuple1 n1 k1 = IndList n1 k1 Source #

type IndTuple2 n1 n2 k1 = (IndList n1 k1, IndList n2 k1) Source #

type IndTuple3 n1 n2 n3 k1 k2 = (IndList n1 k1, IndList n2 k1, IndList n3 k2) Source #

type IndTuple4 n1 n2 n3 n4 k1 k2 = (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2) Source #

type IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3 = (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2, IndList n5 k3) Source #

type IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3 = (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2, IndList n5 k3, IndList n6 k3) Source #

type IndTuple7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 = (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2, IndList n5 k3, IndList n6 k3, IndList n7 k4) Source #

type IndTuple8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 = (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2, IndList n5 k3, IndList n6 k3, IndList n7 k4, IndList n8 k4) Source #

type IndTupleST n1 n2 = (IndList n1 Ind3, IndList n2 Ind3) Source #

Index tuple type for a Tensor that provides only contravariant and covariant spacetime indices, i.e. a STTens.

type IndTupleAbs n1 n2 n3 n4 n5 n6 = (IndList n1 Ind20, IndList n2 Ind20, IndList n3 Ind9, IndList n4 Ind9, IndList n5 Ind3, IndList n6 Ind3) Source #

Index tuple type for a Tensor with indices of type Ind20, ind9 and Ind3 each one appearing contravariantly and covariantly, i.e. a ‘ATens'.

fromListT :: (TIndex k, TAdd v) => [(IndList n k, v)] -> Tensor n k v Source #

This functions construction Tensors with a single index type that only appears contravariantly from a list of key value pairs, where the keys are provided by a IndList that contains the indices under which the corresponding value shall be stored.

The following functions employ the construction of different Tensor types from such typed key value lists.

fromListT1 :: (TIndex k1, TAdd v) => [(IndTuple1 n1 k1, v)] -> AbsTensor1 n1 k1 v Source #

fromListT2 :: (TIndex k1, TAdd v) => [(IndTuple2 n1 n2 k1, v)] -> AbsTensor2 n1 n2 k1 v Source #

fromListT3 :: (TIndex k1, TIndex k2, TAdd v) => [(IndTuple3 n1 n2 n3 k1 k2, v)] -> AbsTensor3 n1 n2 n3 k1 k2 v Source #

fromListT4 :: (TIndex k1, TIndex k2, TAdd v) => [(IndTuple4 n1 n2 n3 n4 k1 k2, v)] -> AbsTensor4 n1 n2 n3 n4 k1 k2 v Source #

fromListT5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)] -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v Source #

fromListT6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)] -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v Source #

fromListT7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => [(IndTuple7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4, v)] -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v Source #

fromListT8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => [(IndTuple8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4, v)] -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v Source #

fromListT' :: forall n k v. (TIndex k, TAdd v, KnownNat n) => [([k], v)] -> Tensor n k v Source #

Same functionality as fromListT but the indices of the various values are specified by usual list. This is certainly more flexible however all at the cost of reduced type safety compared to fromListT.

The following functions employ the construction of different Tensor types from un-typed key value lists.

fromListT1' :: forall n1 k1 v. (KnownNat n1, TIndex k1, TAdd v) => [([k1], v)] -> AbsTensor1 n1 k1 v Source #

fromListT2' :: forall n1 n2 k1 v. (KnownNat n1, KnownNat n2, TIndex k1, TAdd v) => [(([k1], [k1]), v)] -> AbsTensor2 n1 n2 k1 v Source #

fromListT3' :: forall n1 n2 n3 k1 k2 v. (KnownNat n1, KnownNat n2, KnownNat n3, TIndex k1, TIndex k2, TAdd v) => [(([k1], [k1], [k2]), v)] -> AbsTensor3 n1 n2 n3 k1 k2 v Source #

fromListT4' :: forall n1 n2 n3 n4 k1 k2 v. (KnownNat n1, KnownNat n2, KnownNat n3, KnownNat n4, TIndex k1, TIndex k2, TAdd v) => [(([k1], [k1], [k2], [k2]), v)] -> AbsTensor4 n1 n2 n3 n4 k1 k2 v Source #

fromListT5' :: forall n1 n2 n3 n4 n5 k1 k2 k3 v. (KnownNat n1, KnownNat n2, KnownNat n3, KnownNat n4, KnownNat n5, TIndex k1, TIndex k2, TIndex k3, TAdd v) => [(([k1], [k1], [k2], [k2], [k3]), v)] -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v Source #

fromListT6' :: forall n1 n2 n3 n4 n5 n6 k1 k2 k3 v. (KnownNat n1, KnownNat n2, KnownNat n3, KnownNat n4, KnownNat n5, KnownNat n6, TIndex k1, TIndex k2, TIndex k3, TAdd v) => [(([k1], [k1], [k2], [k2], [k3], [k3]), v)] -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v Source #

fromListT7' :: forall n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v. (KnownNat n1, KnownNat n2, KnownNat n3, KnownNat n4, KnownNat n5, KnownNat n6, KnownNat n7, TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => [(([k1], [k1], [k2], [k2], [k3], [k3], [k4]), v)] -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v Source #

fromListT8' :: forall n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v. (KnownNat n1, KnownNat n2, KnownNat n3, KnownNat n4, KnownNat n5, KnownNat n6, KnownNat n7, KnownNat n8, TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => [(([k1], [k1], [k2], [k2], [k3], [k3], [k4], [k4]), v)] -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v Source #

## Accessing Deeper Leaf Levels

Given Tensors with multiple index types, i.e. Tensors that themselves have further Tensors attached as their leafs, i.e. as their Scalars one needs a way of accessing these deeper Tensor levels. This is precisely achieved by the following functions. They allow a general function that takes Tensors as arguments to be applied to Tensors that are attached in deeper levels.

mapTo1 :: (v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2 Source #

Synonym for fmap. mapTo1 applies a function to the values of a tensor.

mapTo1 = fmap

mapTo2 :: (v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2 Source #

Applies a function one level deeper than mapTo1. In other words the leaf values of the Tensor at hand must themselves be of type Tensor, mapTo2 then applies a function to the values of these leaf Tensors.

mapTo2 = fmap . fmap

mapTo3 :: (v1 -> v2) -> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2 Source #

Maps a function to the 3rd leaf level.

mapTo3 = fmap . fmap . fmap

mapTo4 :: (v1 -> v2) -> AbsTensor4 n1 n2 n3 n4 k1 k2 v1 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v2 Source #

Maps a function to the 4th leaf level.

mapTo4 = fmap . fmap . fmap . fmap

mapTo5 :: (v1 -> v2) -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2 Source #

Maps a function to the 5th leaf level.

mapTo5 = fmap . fmap . fmap . fmap . fmap

mapTo6 :: (v1 -> v2) -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2 Source #

Maps a function to the 6th leaf level.

mapTo6 = fmap . fmap . fmap . fmap . fmap . fmap

mapTo7 :: (v1 -> v2) -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v1 -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v2 Source #

Maps a function to the 7th leaf level.

mapTo7 = fmap . fmap . fmap . fmap . fmap . fmap . fmap

mapTo8 :: (v1 -> v2) -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v1 -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v2 Source #

Maps a function to the 8th leaf level.

mapTo8 = fmap . fmap . fmap . fmap . fmap . fmap . fmap . fmap

# Tensor Algebra

## Basic Tensor Algebra Operations

The following functions provide the Tensor type with the structure of the usual tensor algebra.

(&+) :: (TIndex k, TAdd v) => Tensor n k v -> Tensor n k v -> Tensor n k v infixl 6 Source #

Addition of two arbitrary tensors. The only requirement is that the corresponding values satisfy the TAdd constraint. In particular this function can also be used for adding tensors that themselves contain tensors as values.

negateTens :: (TIndex k, TAdd v) => Tensor n k v -> Tensor n k v Source #

Negation of an arbitrary Tensor. The function uses the required group property of the tensor values to map each value of the tensors to its additive inverse.

(&*) :: (TIndex k, Prod v v') => Tensor n k v -> Tensor m k v' -> TProd (Tensor n k v) (Tensor m k v') infixl 7 Source #

Tensor product of two Tensors. In the result for each index type the indices of the first Tensor are arranged left of those in the second Tensor argument. The values of the two Tensors must satisfy the Prod constraint.

(&-) :: (TIndex k, TAdd v) => Tensor n k v -> Tensor n k v -> Tensor n k v infixl 6 Source #

Subtraction of two arbitrary Tensors. The only requirement is that the corresponding values satisfy the TAdd constraint. In particular this function can also be used for adding tensors that themselves contain tensors as values.

(&.) :: (TIndex k, Prod s v) => s -> Tensor n k v -> Tensor n k (TProd s v) infix 8 Source #

Scalar multiplication of an arbitrary Tensor. Only requirement is that the corresponding values and the scalar type satisfy the Prod constraint.

tensorContr :: (TIndex k, TAdd v) => (Int, Int) -> Tensor2 n1 n2 k v -> Tensor2 (n1 - 1) (n2 - 1) k v Source #

This functions compute the contraction of a Tensor in two of its indices of the same index type, i.e. the function sets the two indices equal and sums over their whole index range.

If the indices that are to be contracted do not correspond to the first index type of the given Tensor the following functions can be used.

contrATens1 :: (TIndex k1, TAdd v) => (Int, Int) -> AbsTensor2 (n1 + 1) (n2 + 1) k1 v -> AbsTensor2 n1 n2 k1 v Source #

contrATens1 is a synonym for tensorContr. It applies the contraction to the 1st index type of a tensor.

contrATens1 = tensorContr

contrATens2 :: (TIndex k1, TIndex k2, TAdd v) => (Int, Int) -> AbsTensor4 n1 n2 (n3 + 1) (n4 + 1) k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v Source #

contrATens2 applies the contraction to the 2nd index type of a tensor.

contrATens2 = mapTo2 . tensorContr

contrATens3 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => (Int, Int) -> AbsTensor6 n1 n2 n3 n4 (n5 + 1) (n6 + 1) k1 k2 k3 v -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v Source #

contrATens3 applies the contraction to the 3rd index type of a tensor.

contrATens3 = mapTo4 . tensorContr

contrATens4 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => (Int, Int) -> AbsTensor8 n1 n2 n3 n4 n5 n6 (n7 + 1) (n8 + 1) k1 k2 k3 k4 v -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v Source #

contrATens4 applies the contraction to the 4th index type of a tensor.

contrATens4 = mapTo6 . tensorContr

## Rearranging indices

### Swapping 2 Indices

tensorTrans :: (TIndex k, TAdd v) => (Int, Int) -> Tensor n k v -> Tensor n k v Source #

Transpose a Tensor in two specified contravariant indices of the first index type indices. The result is simply the tensor with the two indices with position specified by the two Int values swapped.

If the indices that are to be transposed do not correspond to the first index type of the given Tensor the following functions can be used.

tensorTrans1 :: (TIndex k1, TAdd v) => (Int, Int) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v Source #

tensorTrans1 = tensorTrans

tensorTrans2 :: (TIndex k1, TAdd v) => (Int, Int) -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v Source #

tensorTrans2 mapTo1 . tensorTrans

tensorTrans3 :: (TIndex k1, TIndex k2, TAdd v) => (Int, Int) -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v Source #

tensorTrans3 = mapTo2 . tensorTrans

tensorTrans4 :: (TIndex k1, TIndex k2, TAdd v) => (Int, Int) -> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v Source #

tensorTrans4 = mapTo3 tensorTrans

tensorTrans5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => (Int, Int) -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v Source #

tensorTrans5 = mapTo4 . tensorTrans

tensorTrans6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => (Int, Int) -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v Source #

tensorTrans6 = mapTo5 . tensorTrans

tensorTrans7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => (Int, Int) -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v Source #

tensorTrans7 = mapTo6 . tensorTrans

tensorTrans8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => (Int, Int) -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v Source #

tensorTrans8 = mapTo7 . tensorTrans

### Swapping 2 index Blocks

tensorBlockTrans :: (TIndex k, TAdd v) => ([Int], [Int]) -> Tensor n k v -> Tensor n k v Source #

Swap, i.e. transpose two index blocks in a given Tensor. The two index blocks must be disjoint.

If the index blocks that are to be transposed do not correspond to the first index type of the given Tensor the following functions can be used.

tensorBlockTrans1 :: (TIndex k1, TAdd v) => ([Int], [Int]) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v Source #

tensorBlockTrans1 = tensorBlockTrans

tensorBlockTrans2 :: (TIndex k1, TAdd v) => ([Int], [Int]) -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v Source #

tensorBlockTrans2 = mapTo1 tensorBlockTrans

tensorBlockTrans3 :: (TIndex k1, TIndex k2, TAdd v) => ([Int], [Int]) -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v Source #

tensorBlockTrans3 = mapTo2 . tensorBlockTrans

tensorBlockTrans4 :: (TIndex k1, TIndex k2, TAdd v) => ([Int], [Int]) -> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v Source #

tensorBlockTrans4 = mapTo3 . tensorBlockTrans

tensorBlockTrans5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => ([Int], [Int]) -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v Source #

tensorBlockTrans5 = mapTo4 . tensorBlockTrans

tensorBlockTrans6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => ([Int], [Int]) -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v Source #

tensorBlockTrans6 = mapTo5 . tensorBlockTrans

tensorBlockTrans7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => ([Int], [Int]) -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v Source #

tensorBlockTrans7 = mapTo6 . tensorBlockTrans

tensorBlockTrans8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => ([Int], [Int]) -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v Source #

tensorBlockTrans8 = mapTo7 tensorBlockTrans

### Permuting indices

resortTens :: (KnownNat n, TIndex k, TAdd v) => [Int] -> Tensor n k v -> Tensor n k v Source #

Completely permute the indices of a given tensor. The new index order is specified by a list '[Int]' that must be of length given by the number of indices the tensor contains. The list then specifies in its i-th element the position on which the i-th index of the tensor shall be sorted.

resortTens [1,2,0,3] (fromListT' [([0,1,2,3],1)] :: Tensor 4 Ind3 Rational) = (fromListT' [([2,0,1,3],1)] :: Tensor 4 Ind3 Rational)

If the indices that are to be permuted do not correspond to the first index type of the given Tensor the following functions can be used.

resortTens1 :: (KnownNat n1, TIndex k1, TAdd v) => [Int] -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v Source #

resortTens1 = resortTens

resortTens2 :: (KnownNat n2, TIndex k1, TAdd v) => [Int] -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v Source #

resortTens2 = mapTo1 . resortTens

resortTens3 :: (KnownNat n3, TIndex k1, TIndex k2, TAdd v) => [Int] -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v Source #

resortTens3 = mapTo2 . resortTens

resortTens4 :: (KnownNat n4, TIndex k1, TIndex k2, TAdd v) => [Int] -> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v Source #

resortTens4 = mapTo3 . resortTens

resortTens5 :: (KnownNat n5, TIndex k1, TIndex k2, TIndex k3, TAdd v) => [Int] -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v Source #

resortTens5 = mapTo4 . resortTens

resortTens6 :: (KnownNat n6, TIndex k1, TIndex k2, TIndex k3, TAdd v) => [Int] -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v Source #

resortTens6 = mapTo5 . resortTens

resortTens7 :: (KnownNat n7, TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => [Int] -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v Source #

resortTens7 = mapTo6 . resortTens

resortTens8 :: (KnownNat n8, TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => [Int] -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v Source #

resortTens8 = mapTo7 . resortTens

## Symmetrization of Tensors

### Pair Symmetrization

symTens :: (TIndex k, TAdd v) => (Int, Int) -> Tensor n k v -> Tensor n k v Source #

Basic symmetrization in a pair of contravariant indices of the 1st index type. Usual factors of $$\frac{1}{2}$$ are not include in this function. The resulting function hence no longer satisfies the property of a projection. The following functions apply symTens to the index types of the deeper leaf levels, i.e. covariant indices of the 1st index type, contravariant indices of the 2nd index type, etc.

If the indices in which the Tensor shall be symmetrized do not correspond to the first index type of the given Tensor the following functions can be used.

symATens1 :: (TIndex k1, TAdd v) => (Int, Int) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v Source #

symATens1 = symTens

symATens2 :: (TIndex k1, TAdd v) => (Int, Int) -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v Source #

symATens2 = mapTo1 . symTens

symATens3 :: (TIndex k1, TIndex k2, TAdd v) => (Int, Int) -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v Source #

symATens3 = mapTo2 . symTens

symATens4 :: (TIndex k1, TIndex k2, TAdd v) => (Int, Int) -> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v Source #

symATens4 = mapTo3 . symTens

symATens5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => (Int, Int) -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v Source #

symATens5 = mapTo4 . symTens

symATens6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => (Int, Int) -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v Source #

symATens6 = mapTo5 . symTens

symATens7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => (Int, Int) -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v Source #

symATens7 = mapTo6 . symTens

symATens8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => (Int, Int) -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v Source #

symATens8 = mapTo7 . symTens

symTensFac :: (TIndex k, TAdd v, Prod (SField Rational) v) => (Int, Int) -> Tensor n k v -> Tensor n k (TProd (SField Rational) v) Source #

Same functionality as symTens but including the $$\frac{1}{2}$$ in the result and thus defining a projection. The following functions apply symTensFac to the index types of the deeper leaf levels, i.e. covariant indices of the 1st index type, contravariant indices of the 2nd index type, etc.

symTensFac inds t = SField (1/2 :: Rational) &. symTens inds t

If the indices in which the Tensor shall be symmetrized do not correspond to the first index type of the given Tensor the following functions can be used.

symATensFac1 :: (TIndex k1, TAdd v, Prod (SField Rational) v) => (Int, Int) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 (TProd (SField Rational) v) Source #

symATensFac1 = symTensFac

symATensFac2 :: (TIndex k1, TAdd v, Prod (SField Rational) v) => (Int, Int) -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v) Source #

symATensFac2 = mapTo1 . symTensFac

symATensFac3 :: (TIndex k1, TIndex k2, TAdd v, Prod (SField Rational) v) => (Int, Int) -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v) Source #

symATensFac3 = mapTo2 . symTensFac

symATensFac4 :: (TIndex k1, TIndex k2, TAdd v, Prod (SField Rational) v) => (Int, Int) -> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v) Source #

symATensFac4 = mapTo3 . symTensFac

symATensFac5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v, Prod (SField Rational) v) => (Int, Int) -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v) Source #

symATensFac5 = mapTo4 . symTensFac

symATensFac6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v, Prod (SField Rational) v) => (Int, Int) -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (TProd (SField Rational) v) Source #

symATensFac6 = mapTo5 . symTensFac

symATensFac7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v, Prod (SField Rational) v) => (Int, Int) -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (TProd (SField Rational) v) Source #

symATensFac7 = mapTo6 . symTensFac

symATensFac8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v, Prod (SField Rational) v) => (Int, Int) -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (TProd (SField Rational) v) Source #

symATensFac8 = mapTo7 . symTensFac

### Pair Anti Symmetrization

aSymTens :: (TIndex k, TAdd v) => (Int, Int) -> Tensor n k v -> Tensor n k v Source #

Basic anti symmetrization in a pair of contravariant indices of the 1st index type. Usual factors of $$\frac{1}{2}$$ are not include in this function. The resulting function hence no longer satisfies the property of a projection. The following functions apply aSymTens to the index types of the deeper leaf levels, i.e. covariant indices of the 1st index type, contravariant indices of the 2nd index type, etc.

If the indices in which the Tensor shall be anti symmetrized do not correspond to the first index type of the given Tensor the following functions can be used.

aSymATens1 :: (TIndex k1, TAdd v) => (Int, Int) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v Source #

aSymATens1 = aSymTens

aSymATens2 :: (TIndex k1, TAdd v) => (Int, Int) -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v Source #

aSymATens2 = mapTo1 . aSymTens

aSymATens3 :: (TIndex k1, TIndex k2, TAdd v) => (Int, Int) -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v Source #

aSymATens3 = mapTo2 . aSymTens

aSymATens4 :: (TIndex k1, TIndex k2, TAdd v) => (Int, Int) -> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v Source #

aSymATens4 = mapTo3 . aSymTens

aSymATens5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => (Int, Int) -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v Source #

aSymATens5 = mapTo4 . aSymTens

aSymATens6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => (Int, Int) -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v Source #

aSymATens6 = mapTo5 . aSymTens

aSymATens7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => (Int, Int) -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v Source #

aSymATens7 = mapTo6 . aSymTens

aSymATens8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => (Int, Int) -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v Source #

aSymATens8 = mapTo7 . aSymTens

aSymTensFac :: (TIndex k, TAdd v, Prod (SField Rational) v) => (Int, Int) -> Tensor n k v -> Tensor n k (TProd (SField Rational) v) Source #

Same functionality as aSymTens but including the $$\frac{1}{2}$$ factors in the result and thus defining a projection. The following functions apply aSymTensFac to the index types of the deeper leaf levels, i.e. covariant indices of the 1st index type, contravariant indices of the 2nd index type, etc.

aSymTensFac inds t = SField (1/2 :: Rational) &. aSymTens inds t

If the indices in which the Tensor shall be anti symmetrized do not correspond to the first index type of the given Tensor the following functions can be used.

aSymATensFac1 :: (TIndex k1, TAdd v, Prod (SField Rational) v) => (Int, Int) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 (TProd (SField Rational) v) Source #

aSymATensFac1 = aSymTensFac

aSymATensFac2 :: (TIndex k1, TAdd v, Prod (SField Rational) v) => (Int, Int) -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v) Source #

aSymATensFac2 = mapTo1 . aSymTensFac

aSymATensFac3 :: (TIndex k1, TIndex k2, TAdd v, Prod (SField Rational) v) => (Int, Int) -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v) Source #

aSymATensFac3 = mapTo2 . aSymTensFac

aSymATensFac4 :: (TIndex k1, TIndex k2, TAdd v, Prod (SField Rational) v) => (Int, Int) -> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v) Source #

aSymATensFac4 = mapTo3 . aSymTensFac

aSymATensFac5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v, Prod (SField Rational) v) => (Int, Int) -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v) Source #

aSymATensFac5 = mapTo4 . aSymTensFac

aSymATensFac6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v, Prod (SField Rational) v) => (Int, Int) -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (TProd (SField Rational) v) Source #

aSymATensFac6 = mapTo5 . aSymTensFac

aSymATensFac7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v, Prod (SField Rational) v) => (Int, Int) -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (TProd (SField Rational) v) Source #

aSymATensFac7 = mapTo6 . aSymTensFac

aSymATensFac8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v, Prod (SField Rational) v) => (Int, Int) -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (TProd (SField Rational) v) Source #

aSymATensFac8 = mapTo7 . aSymTensFac

### Block Exchange Symmetrization

symBlockTens :: (TIndex k, TAdd v) => ([Int], [Int]) -> Tensor n k v -> Tensor n k v Source #

Symmetrization w.r.t. the exchange of two blocks of contravariant indices of the 1st index type. The index blocks must be disjoint. These function does not include the usual $$\frac{1}{2}$$ factors and thus does not define a projection. The following functions apply symBlockTens to the index types of the deeper leaf levels, i.e. covariant indices of the 1st index type, contravariant indices of the 2nd index type, etc.

If the index blocks in which the Tensor shall be symmetrized do not correspond to the first index type of the given Tensor the following functions can be used.

symBlockATens1 :: (TIndex k1, TAdd v) => ([Int], [Int]) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v Source #

symBlockATens1 = symBlockTens

symBlockATens2 :: (TIndex k1, TAdd v) => ([Int], [Int]) -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v Source #

symBlockATens2 = mapTo1 . symBlockTens

symBlockATens3 :: (TIndex k1, TIndex k2, TAdd v) => ([Int], [Int]) -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v Source #

symBlockATens3 = mapTo2 . symBlockTens

symBlockATens4 :: (TIndex k1, TIndex k2, TAdd v) => ([Int], [Int]) -> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v Source #

symBlockATens4 = mapTo3 . symBlockTens

symBlockATens5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => ([Int], [Int]) -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v Source #

symBlockATens5 = mapTo4 . symBlockTens

symBlockATens6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => ([Int], [Int]) -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v Source #

symBlockATens6 = mapTo5 . symBlockTens

symBlockATens7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => ([Int], [Int]) -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v Source #

symBlockATens7 = mapTo6 . symBlockTens

symBlockATens8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => ([Int], [Int]) -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v Source #

symBlockATens8 = mapTo7 . symBlockTens

symBlockTensFac :: (TIndex k, TAdd v, Prod (SField Rational) v) => ([Int], [Int]) -> Tensor n k v -> Tensor n k (TProd (SField Rational) v) Source #

Same functionality as symBlockTens but including the usual factors of $$\frac{1}{2}$$ in the result and thus defining a projection. The following functions apply symBlockTensFac to the index types of the deeper leaf levels, i.e. covariant indices of the 1st index type, contravariant indices of the 2nd index type, etc.

symBlockTensFac inds t = SField (1/2 :: Rational) &. symBlockTens inds t

If the index blocks in which the Tensor shall be symmetrized do not correspond to the first index type of the given Tensor the following functions can be used.

symBlockATensFac1 :: (TIndex k1, TAdd v, Prod (SField Rational) v) => ([Int], [Int]) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 (TProd (SField Rational) v) Source #

symBlockATensFac1 = symBlockTensFac

symBlockATensFac2 :: (TIndex k1, TAdd v, Prod (SField Rational) v) => ([Int], [Int]) -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v) Source #

symBlockATensFac2 = mapTo1 . symBlockTensFac

symBlockATensFac3 :: (TIndex k1, TIndex k2, TAdd v, Prod (SField Rational) v) => ([Int], [Int]) -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v) Source #

symBlockATensFac3 = mapTo2 . symBlockTensFac

symBlockATensFac4 :: (TIndex k1, TIndex k2, TAdd v, Prod (SField Rational) v) => ([Int], [Int]) -> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v) Source #

symBlockATensFac4 = mapTo3 . symBlockTensFac

symBlockATensFac5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v, Prod (SField Rational) v) => ([Int], [Int]) -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v) Source #

symBlockATensFac5 = mapTo4 . symBlockTensFac

symBlockATensFac6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v, Prod (SField Rational) v) => ([Int], [Int]) -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (TProd (SField Rational) v) Source #

symBlockATensFac6 = mapTo5 . symBlockTensFac

symBlockATensFac7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v, Prod (SField Rational) v) => ([Int], [Int]) -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (TProd (SField Rational) v) Source #

symBlockATensFac7 = mapTo6 . symBlockTensFac

symBlockATensFac8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v, Prod (SField Rational) v) => ([Int], [Int]) -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (TProd (SField Rational) v) Source #

symBlockATensFac8 = mapTo7 . symBlockTensFac

### Block Exchange Anti Symmetrization

aSymBlockTens :: (TIndex k, TAdd v) => ([Int], [Int]) -> Tensor n k v -> Tensor n k v Source #

Anti symmetrization w.r.t. the exchange of two blocks of contravariant indices of the 1st index type. The index blocks must be disjoint. These function does not include the usual $$\frac{1}{2}$$ factors and thus does not define a projection. The following functions apply aSymBlockTens to the index types of the deeper leaf levels, i.e. covariant indices of the 1st index type, contravariant indices of the 2nd index type, etc.

If the index blocks in which the Tensor shall be anti symmetrized do not correspond to the first index type of the given Tensor the following functions can be used.

aSymBlockATens1 :: (TIndex k1, TAdd v) => ([Int], [Int]) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v Source #

aSymBlockATens1 = aSymBlockTens

aSymBlockATens2 :: (TIndex k1, TAdd v) => ([Int], [Int]) -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v Source #

aSymBlockATens2 = mapTo1 . aSymBlockTens

aSymBlockATens3 :: (TIndex k1, TIndex k2, TAdd v) => ([Int], [Int]) -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v Source #

aSymBlockATens3 = mapTo2 . aSymBlockTens

aSymBlockATens4 :: (TIndex k1, TIndex k2, TAdd v) => ([Int], [Int]) -> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v Source #

aSymBlockATens4 = mapTo3 . aSymBlockTens

aSymBlockATens5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => ([Int], [Int]) -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v Source #

aSymBlockATens5 = mapTo4 . aSymBlockTens

aSymBlockATens6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => ([Int], [Int]) -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v Source #

aSymBlockATens6 = mapTo5 . aSymBlockTens

aSymBlockATens7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => ([Int], [Int]) -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v Source #

aSymBlockATens7 = mapTo6 . aSymBlockTens

aSymBlockATens8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => ([Int], [Int]) -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v Source #

aSymBlockATens8 = mapTo7 . aSymBlockTens

aSymBlockTensFac :: (TIndex k, TAdd v, Prod (SField Rational) v) => ([Int], [Int]) -> Tensor n k v -> Tensor n k (TProd (SField Rational) v) Source #

Same functionality as aSymBlockTens but including the usual factors of $$\frac{1}{2}$$ in the result and thus defining a projection. The following functions apply aSymBlockTensFac to the index types of the deeper leaf levels, i.e. covariant indices of the 1st index type, contravariant indices of the 2nd index type, etc.

aSymBlockTensFac inds t = SField (1/2 :: Rational) &. aSymBlockTens inds t

If the index blocks in which the Tensor shall be anti symmetrized do not correspond to the first index type of the given Tensor the following functions can be used.

aSymBlockATensFac1 :: (TIndex k1, TAdd v, Prod (SField Rational) v) => ([Int], [Int]) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 (TProd (SField Rational) v) Source #

aSymBlockATensFac1 = aSymBlockTensFac

aSymBlockATensFac2 :: (TIndex k1, TAdd v, Prod (SField Rational) v) => ([Int], [Int]) -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v) Source #

aSymBlockATensFac2 = mapTo1 . aSymBlockTensFac

aSymBlockATensFac3 :: (TIndex k1, TIndex k2, TAdd v, Prod (SField Rational) v) => ([Int], [Int]) -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v) Source #

aSymBlockATensFac3 = mapTo2 . aSymBlockTensFac

aSymBlockATensFac4 :: (TIndex k1, TIndex k2, TAdd v, Prod (SField Rational) v) => ([Int], [Int]) -> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v) Source #

aSymBlockATensFac4 = mapTo3 . aSymBlockTensFac

aSymBlockATensFac5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v, Prod (SField Rational) v) => ([Int], [Int]) -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v) Source #

aSymBlockATensFac5 = mapTo4 . aSymBlockTensFac

aSymBlockATensFac6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v, Prod (SField Rational) v) => ([Int], [Int]) -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (TProd (SField Rational) v) Source #

aSymBlockATensFac6 = mapTo5 . aSymBlockTensFac

aSymBlockATensFac7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v, Prod (SField Rational) v) => ([Int], [Int]) -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (TProd (SField Rational) v) Source #

aSymBlockATensFac7 = mapTo6 . aSymBlockTensFac

aSymBlockATensFac8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v, Prod (SField Rational) v) => ([Int], [Int]) -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (TProd (SField Rational) v) Source #

aSymBlockATensFac8 = mapTo7 . aSymBlockTensFac

### Cyclic Symmetrization

cyclicSymTens :: (TIndex k, TAdd v) => [Int] -> Tensor n k v -> Tensor n k v Source #

Cyclic symmetrization of the specified subset of contravariant Tensor indices of the first index type. The function does not include usual factors of $$\frac{1}{i!}$$ where $$i$$ is the number of indices w.r.t. which the symmetrization is performed. Further functions that are displayed below apply cyclicSymTens to the various deeper Tensor levels.

If the indices in which the Tensor shall be symmetrized do not correspond to the first index type of the given Tensor the following functions can be used.

cyclicSymATens1 :: (TIndex k1, TAdd v) => [Int] -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v Source #

cyclicSymATens1 = cyclicSymTens

cyclicSymATens2 :: (TIndex k1, TAdd v) => [Int] -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v Source #

cyclicSymATens2 = mapTo1 . cyclicSymTens

cyclicSymATens3 :: (TIndex k1, TIndex k2, TAdd v) => [Int] -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v Source #

cyclicSymATens3 = mapTo2 . cyclicSymTens

cyclicSymATens4 :: (TIndex k1, TIndex k2, TAdd v) => [Int] -> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v Source #

cyclicSymATens4 = mapTo3 . cyclicSymTens

cyclicSymATens5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => [Int] -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v Source #

cyclicSymATens5 = mapTo4 . cyclicSymTens

cyclicSymATens6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => [Int] -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v Source #

cyclicSymATens6 = mapTo5 . cyclicSymTens

cyclicSymATens7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => [Int] -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v Source #

cyclicSymATens7 = mapTo6 . cyclicSymTens

cyclicSymATens8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => [Int] -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v Source #

cyclicSymATens8 = mapTo7 . cyclicSymTens

cyclicSymTensFac :: (TIndex k, TAdd v, Prod (SField Rational) v) => [Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v) Source #

This function provides the same functionality as cyclicSymTens with the only difference that it includes the $$\frac{1}{i!}$$ factors. The functions that are further provided apply cyclicSymTensFac to deeper Tensor levels.

cyclicSymTensFac inds t = fac &. cyclicSymTens inds t

If the indices in which the Tensor shall be symmetrized do not correspond to the first index type of the given Tensor the following functions can be used.

cyclicSymATensFac1 :: (TIndex k1, TAdd v, Prod (SField Rational) v) => [Int] -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 (TProd (SField Rational) v) Source #

cyclicSymATensFac1 = cyclicSymTensFac

cyclicSymATensFac2 :: (TIndex k1, TAdd v, Prod (SField Rational) v) => [Int] -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v) Source #

cyclicSymATensFac2 = mapTo1 . cyclicSymTensFac

cyclicSymATensFac3 :: (TIndex k1, TIndex k2, TAdd v, Prod (SField Rational) v) => [Int] -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v) Source #

cyclicSymATensFac3 = mapTo2 . cyclicSymTensFac

cyclicSymATensFac4 :: (TIndex k1, TIndex k2, TAdd v, Prod (SField Rational) v) => [Int] -> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v) Source #

cyclicSymATensFac4 = mapTo3 . cyclicSymTensFac

cyclicSymATensFac5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v, Prod (SField Rational) v) => [Int] -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v) Source #

cyclicSymATensFac5 = mapTo4 . cyclicSymTensFac

cyclicSymATensFac6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v, Prod (SField Rational) v) => [Int] -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (TProd (SField Rational) v) Source #

cyclicSymATensFac6 = mapTo5 . cyclicSymTensFac

cyclicSymATensFac7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v, Prod (SField Rational) v) => [Int] -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (TProd (SField Rational) v) Source #

cyclicSymATensFac7 = mapTo6 . cyclicSymTensFac

cyclicSymATensFac8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v, Prod (SField Rational) v) => [Int] -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (TProd (SField Rational) v) Source #

cyclicSymATensFac8 = mapTo7 . cyclicSymTensFac

### Cyclic Anti Symmetrization

cyclicASymTens :: (TIndex k, TAdd v) => [Int] -> Tensor n k v -> Tensor n k v Source #

Cyclic anti symmetrization of the specified subset of contravariant Tensor indices of the first index type. The function does not include usual factors of $$\frac{1}{i!}$$ where $$i$$ is the number of indices w.r.t. which the symmetrization is performed. Further functions that are displayed below apply cyclicASymTens to the various deeper Tensor levels.

If the indices in which the Tensor shall be anti symmetrized do not correspond to the first index type of the given Tensor the following functions can be used.

cyclicASymATens1 :: (TIndex k1, TAdd v) => [Int] -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v Source #

cyclicASymATens1 = cyclicASymTens

cyclicASymATens2 :: (TIndex k1, TAdd v) => [Int] -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v Source #

cyclicASymATens2 = mapTo1 . cyclicASymTens

cyclicASymATens3 :: (TIndex k1, TIndex k2, TAdd v) => [Int] -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v Source #

cyclicASymATens3 = mapTo2 . cyclicASymTens

cyclicASymATens4 :: (TIndex k1, TIndex k2, TAdd v) => [Int] -> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v Source #

cyclicASymATens4 = mapTo3 . cyclicASymTens

cyclicASymATens5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => [Int] -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v Source #

cyclicASymATens5 = mapTo4 . cyclicASymTens

cyclicASymATens6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => [Int] -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v Source #

cyclicASymATens6 = mapTo5 . cyclicASymTens

cyclicASymATens7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => [Int] -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v Source #

cyclicASymATens7 = mapTo6 . cyclicASymTens

cyclicASymATens8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => [Int] -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v Source #

cyclicASymATens8 = mapTo7 . cyclicASymTens

cyclicASymTensFac :: (TIndex k, TAdd v, Prod (SField Rational) v) => [Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v) Source #

This function provides the same functionality as cyclicASymTens with the only difference that it includes the $$\frac{1}{i!}$$ factors. The functions that are further provided apply cyclicASymTensFac to deeper Tensor levels.

cyclicASymTensFac inds t = fac &. cyclicASymTens inds t

If the indices in which the Tensor shall be anti symmetrized do not correspond to the first index type of the given Tensor the following functions can be used.

cyclicASymATensFac1 :: (TIndex k1, TAdd v, Prod (SField Rational) v) => [Int] -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 (TProd (SField Rational) v) Source #

cyclicASymATensFac1 = cyclicASymTensFac

cyclicASymATensFac2 :: (TIndex k1, TAdd v, Prod (SField Rational) v) => [Int] -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v) Source #

cyclicASymATensFac2 = mapTo1 . cyclicASymTensFac

cyclicASymATensFac3 :: (TIndex k1, TIndex k2, TAdd v, Prod (SField Rational) v) => [Int] -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v) Source #

cyclicASymATensFac3 = mapTo2 . cyclicASymTensFac

cyclicASymATensFac4 :: (TIndex k1, TIndex k2, TAdd v, Prod (SField Rational) v) => [Int] -> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v) Source #

cyclicASymATensFac4 = mapTo3 . cyclicASymTensFac

cyclicASymATensFac5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v, Prod (SField Rational) v) => [Int] -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v) Source #

cyclicASymATensFac5 = mapTo4 . cyclicASymTensFac

cyclicASymATensFac6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v, Prod (SField Rational) v) => [Int] -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (TProd (SField Rational) v) Source #

cyclicASymATensFac6 = mapTo5 . cyclicASymTensFac

cyclicASymATensFac7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v, Prod (SField Rational) v) => [Int] -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (TProd (SField Rational) v) Source #

cyclicASymATensFac7 = mapTo6 . cyclicASymTensFac

cyclicASymATensFac8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v, Prod (SField Rational) v) => [Int] -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (TProd (SField Rational) v) Source #

cyclicASymATensFac8 = mapTo7 . cyclicASymTensFac

### Cyclic Block Symmetrization

cyclicBlockSymTens :: (TIndex k, TAdd v) => [[Int]] -> Tensor n k v -> Tensor n k v Source #

Cyclic block symmetrization, i.e. symmetrization w.r.t. any permutation of the specified index blocks of contravariant indices of the first index type. Usual factors of $$\frac{1}{i!}$$ where $$i$$ is the number of index blocks w.r.t. which the symmetrization is performed are not included. The functions that are displayed further below apply cyclicBlockSymTens to the various deeper Tensor levels.

If the index blocks in which the Tensor shall be symmetrized do not correspond to the first index type of the given Tensor the following functions can be used.

cyclicBlockSymATens1 :: (TIndex k1, TAdd v) => [[Int]] -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v Source #

cyclicBlockSymATens1 = cyclicBlockSymTens

cyclicBlockSymATens2 :: (TIndex k1, TAdd v) => [[Int]] -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v Source #

cyclicBlockSymATens2 = mapTo1 . cyclicBlockSymTens

cyclicBlockSymATens3 :: (TIndex k1, TIndex k2, TAdd v) => [[Int]] -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v Source #

cyclicBlockSymATens3 = mapTo2 . cyclicBlockSymTens

cyclicBlockSymATens4 :: (TIndex k1, TIndex k2, TAdd v) => [[Int]] -> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v Source #

cyclicBlockSymATens4 = mapTo3 . cyclicBlockSymTens

cyclicBlockSymATens5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => [[Int]] -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v Source #

cyclicBlockSymATens5 = mapTo4 . cyclicBlockSymTens

cyclicBlockSymATens6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => [[Int]] -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v Source #

cyclicBlockSymATens6 = mapTo5 . cyclicBlockSymTens

cyclicBlockSymATens7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => [[Int]] -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v Source #

cyclicBlockSymATens7 = mapTo6 . cyclicBlockSymTens

cyclicBlockSymATens8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => [[Int]] -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v Source #

cyclicBlockSymATens8 = mapTo7 . cyclicBlockSymTens

cyclicBlockSymTensFac :: (TIndex k, TAdd v, Prod (SField Rational) v) => [[Int]] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v) Source #

This function provides the same functionality as cyclicBlockSymTens with the only difference that it includes the $$\frac{1}{i!}$$ factors. The functions that are further provided apply cyclicASymTensFac to deeper Tensor levels.

cyclicBlockSymTensFac inds t = fac &. cyclicBlockSymTens inds t

If the index blocks in which the Tensor shall be symmetrized do not correspond to the first index type of the given Tensor the following functions can be used.

cyclicBlockSymATensFac1 :: (TIndex k1, TAdd v, Prod (SField Rational) v) => [[Int]] -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 (TProd (SField Rational) v) Source #

cyclicBlockSymATensFac1 = cyclicBlockSymTensFac

cyclicBlockSymATensFac2 :: (TIndex k1, TAdd v, Prod (SField Rational) v) => [[Int]] -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v) Source #

cyclicBlockSymATensFac2 = mapTo1 . cyclicBlockSymTensFac

cyclicBlockSymATensFac3 :: (TIndex k1, TIndex k2, TAdd v, Prod (SField Rational) v) => [[Int]] -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v) Source #

cyclicBlockSymATensFac3 = mapTo2 . cyclicBlockSymTensFac

cyclicBlockSymATensFac4 :: (TIndex k1, TIndex k2, TAdd v, Prod (SField Rational) v) => [[Int]] -> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v) Source #

cyclicBlockSymATensFac4 = mapTo3 . cyclicBlockSymTensFac

cyclicBlockSymATensFac5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v, Prod (SField Rational) v) => [[Int]] -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v) Source #

cyclicBlockSymATensFac5 = mapTo4 . cyclicBlockSymTensFac

cyclicBlockSymATensFac6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v, Prod (SField Rational) v) => [[Int]] -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (TProd (SField Rational) v) Source #

cyclicBlockSymATensFac6 = mapTo5 . cyclicBlockSymTensFac

cyclicBlockSymATensFac7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v, Prod (SField Rational) v) => [[Int]] -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (TProd (SField Rational) v) Source #

cyclicBlockSymATensFac7 = mapTo6 . cyclicBlockSymTensFac

cyclicBlockSymATensFac8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v, Prod (SField Rational) v) => [[Int]] -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (TProd (SField Rational) v) Source #

cyclicBlockSymATensFac8 = mapTo7 . cyclicBlockSymTensFac

# Tensor Functions

## Lists of multiple Tensors

Sometimes it is convenient to collect multiple Tensorss with the same value type. To allow the individual Tensors to have different rank these lists are heterogeneous.

data TensList1 k1 v where Source #

Constructors

 EmptyTList1 :: TensList1 k1 v AppendTList1 :: AbsTensor1 n1 k1 v -> TensList1 k1 v -> TensList1 k1 v

data TensList2 k1 v where Source #

Constructors

 EmptyTList2 :: TensList2 k1 v AppendTList2 :: AbsTensor2 n1 n2 k1 v -> TensList2 k1 v -> TensList2 k1 v

data TensList3 k1 k2 v where Source #

Constructors

 EmptyTList3 :: TensList3 k1 k2 v AppendTList3 :: AbsTensor3 n1 n2 n3 k1 k2 v -> TensList3 k1 k2 v -> TensList3 k1 k2 v

data TensList4 k1 k2 v where Source #

Constructors

 EmptyTList4 :: TensList4 k1 k2 v AppendTList4 :: AbsTensor4 n1 n2 n3 n4 k1 k2 v -> TensList4 k1 k2 v -> TensList4 k1 k2 v

data TensList5 k1 k2 k3 v where Source #

Constructors

 EmptyTList5 :: TensList5 k1 k2 k3 v AppendTList5 :: AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> TensList5 k1 k2 k3 v -> TensList5 k1 k2 k3 v

data TensList6 k1 k2 k3 v where Source #

Constructors

 EmptyTList6 :: TensList6 k1 k2 k3 v AppendTList6 :: AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> TensList6 k1 k2 k3 v -> TensList6 k1 k2 k3 v

data TensList7 k1 k2 k3 k4 v where Source #

Constructors

 EmptyTList7 :: TensList7 k1 k2 k3 k4 v AppendTList7 :: AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> TensList7 k1 k2 k3 k4 v -> TensList7 k1 k2 k3 k4 v

data TensList8 k1 k2 k3 k4 v where Source #

Constructors

 EmptyTList8 :: TensList8 k1 k2 k3 k4 v AppendTList8 :: AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> TensList8 k1 k2 k3 k4 v -> TensList8 k1 k2 k3 k4 v

Construction of a such heterogeneous list with a single Tensor as Entry.

singletonTList3 :: AbsTensor3 n1 n2 n3 k1 k2 v -> TensList3 k1 k2 v Source #

singletonTList4 :: AbsTensor4 n1 n2 n3 n4 k1 k2 v -> TensList4 k1 k2 v Source #

singletonTList5 :: AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> TensList5 k1 k2 k3 v Source #

singletonTList6 :: AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> TensList6 k1 k2 k3 v Source #

singletonTList7 :: AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> TensList7 k1 k2 k3 k4 v Source #

singletonTList8 :: AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> TensList8 k1 k2 k3 k4 v Source #

Infix Synonyms for the various constructors such as AppendTList1, AppendTList2, etc.

(...>) :: AbsTensor1 n1 k1 v -> TensList1 k1 v -> TensList1 k1 v infixr 5 Source #

(..&>) :: AbsTensor2 n1 n2 k1 v -> TensList2 k1 v -> TensList2 k1 v infixr 5 Source #

(.&.>) :: AbsTensor3 n1 n2 n3 k1 k2 v -> TensList3 k1 k2 v -> TensList3 k1 k2 v infixr 5 Source #

(.&&>) :: AbsTensor4 n1 n2 n3 n4 k1 k2 v -> TensList4 k1 k2 v -> TensList4 k1 k2 v infixr 5 Source #

(&..>) :: AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> TensList5 k1 k2 k3 v -> TensList5 k1 k2 k3 v infixr 5 Source #

(&.&>) :: AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> TensList6 k1 k2 k3 v -> TensList6 k1 k2 k3 v infixr 5 Source #

(&&.>) :: AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> TensList7 k1 k2 k3 k4 v -> TensList7 k1 k2 k3 k4 v infixr 5 Source #

(&&&>) :: AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> TensList8 k1 k2 k3 k4 v -> TensList8 k1 k2 k3 k4 v infixr 5 Source #

Combining functions for the separate heterogeneous tensor lists.

(...+) :: TensList1 k1 v -> TensList1 k1 v -> TensList1 k1 v infixr 5 Source #

(..&+) :: TensList2 k1 v -> TensList2 k1 v -> TensList2 k1 v infixr 5 Source #

(.&.+) :: TensList3 k1 k2 v -> TensList3 k1 k2 v -> TensList3 k1 k2 v infixr 5 Source #

(.&&+) :: TensList4 k1 k2 v -> TensList4 k1 k2 v -> TensList4 k1 k2 v infixr 5 Source #

(&..+) :: TensList5 k1 k2 k3 v -> TensList5 k1 k2 k3 v -> TensList5 k1 k2 k3 v infixr 5 Source #

(&.&+) :: TensList6 k1 k2 k3 v -> TensList6 k1 k2 k3 v -> TensList6 k1 k2 k3 v infixr 5 Source #

(&&.+) :: TensList7 k1 k2 k3 k4 v -> TensList7 k1 k2 k3 k4 v -> TensList7 k1 k2 k3 k4 v infixr 5 Source #

(&&&+) :: TensList8 k1 k2 k3 k4 v -> TensList8 k1 k2 k3 k4 v -> TensList8 k1 k2 k3 k4 v infixr 5 Source #

## Conversion of Tensors

### To List

toListT :: Tensor n k v -> [(IndList n k, v)] Source #

The following function converts a Tensor to a typed index tuple list, i.e. a list of key value pairs with keys of type IndList and values being the corresponding Tensor value.

Converting the various Tensors with multiple different index types to such typed lists.

toListT1 :: AbsTensor1 n1 k1 v -> [(IndTuple1 n1 k1, v)] Source #

toListT2 :: AbsTensor2 n1 n2 k1 v -> [(IndTuple2 n1 n2 k1, v)] Source #

toListT3 :: AbsTensor3 n1 n2 n3 k1 k2 v -> [(IndTuple3 n1 n2 n3 k1 k2, v)] Source #

toListT4 :: AbsTensor4 n1 n2 n3 n4 k1 k2 v -> [(IndTuple4 n1 n2 n3 n4 k1 k2, v)] Source #

toListT5 :: AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)] Source #

toListT6 :: AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)] Source #

toListT7 :: AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> [(IndTuple7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4, v)] Source #

toListT8 :: AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> [(IndTuple8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4, v)] Source #

toListT' :: (TIndex k, TAdd v) => Tensor n k v -> [([Int], v)] Source #

This function converts a given Tensor to a non-typed index tuple list.

Converting the various Tensors with multiple different index types to such non-typed lists.

toListT1' :: (TIndex k1, TAdd v) => AbsTensor1 n1 k1 v -> [([Int], v)] Source #

toListT2' :: (TIndex k1, TAdd v) => AbsTensor2 n1 n2 k1 v -> [(([Int], [Int]), v)] Source #

toListT3' :: (TIndex k1, TIndex k2, TAdd v) => AbsTensor3 n1 n2 n3 k1 k2 v -> [(([Int], [Int], [Int]), v)] Source #

toListT4' :: (TIndex k1, TIndex k2, TAdd v) => AbsTensor4 n1 n2 n3 n4 k1 k2 v -> [(([Int], [Int], [Int], [Int]), v)] Source #

toListT5' :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> [(([Int], [Int], [Int], [Int], [Int]), v)] Source #

toListT6' :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> [(([Int], [Int], [Int], [Int], [Int], [Int]), v)] Source #

toListT7' :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> [(([Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)] Source #

toListT8' :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> [(([Int], [Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)] Source #

### To Matrix

Convert a tensor that stores AnsVar values to a matrix where the columns label the variables in AnsVar and the rows label independent components of the tensor.

Convert a Tensor to a sparse matrix assocs list.

toMatListT1' :: (TIndex k1, TAdd a) => AbsTensor1 n1 k1 (AnsVar a) -> [((Int, Int), a)] Source #

toMatListT2' :: (TIndex k1, TAdd a) => AbsTensor2 n1 n2 k1 (AnsVar a) -> [((Int, Int), a)] Source #

toMatListT3' :: (TIndex k1, TIndex k2, TAdd a) => AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a) -> [((Int, Int), a)] Source #

toMatListT4' :: (TIndex k1, TIndex k2, TAdd a) => AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a) -> [((Int, Int), a)] Source #

toMatListT5' :: (TIndex k1, TIndex k2, TIndex k3, TAdd a) => AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a) -> [((Int, Int), a)] Source #

toMatListT6' :: (TIndex k1, TIndex k2, TIndex k3, TAdd a) => AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a) -> [((Int, Int), a)] Source #

toMatListT7' :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd a) => AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar a) -> [((Int, Int), a)] Source #

toMatListT8' :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd a) => AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar a) -> [((Int, Int), a)] Source #

toMatrixT3' :: (TIndex k1, TIndex k2, Real a) => AbsTensor3 n1 n2 n3 k1 k2 (AnsVar (SField a)) -> Matrix Double Source #

toMatrixT4' :: (TIndex k1, TIndex k2, Real a) => AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar (SField a)) -> Matrix Double Source #

toMatrixT5' :: (TIndex k1, TIndex k2, TIndex k3, Real a) => AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar (SField a)) -> Matrix Double Source #

toMatrixT6' :: (TIndex k1, TIndex k2, TIndex k3, Real a) => AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar (SField a)) -> Matrix Double Source #

toMatrixT7' :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, Real a) => AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar (SField a)) -> Matrix Double Source #

toMatrixT8' :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, Real a) => AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar (SField a)) -> Matrix Double Source #

Convert all Tensors of a heterogeneous tensor List to a combined sparse matrix assocs list.

toMatListT1 :: (TIndex k1, TAdd a) => TensList1 k1 (AnsVar a) -> [((Int, Int), a)] Source #

toMatListT2 :: (TIndex k1, TAdd a) => TensList2 k1 (AnsVar a) -> [((Int, Int), a)] Source #

toMatListT3 :: (TIndex k1, TIndex k2, TAdd a) => TensList3 k1 k2 (AnsVar a) -> [((Int, Int), a)] Source #

toMatListT4 :: (TIndex k1, TIndex k2, TAdd a) => TensList4 k1 k2 (AnsVar a) -> [((Int, Int), a)] Source #

toMatListT5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd a) => TensList5 k1 k2 k3 (AnsVar a) -> [((Int, Int), a)] Source #

toMatListT6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd a) => TensList6 k1 k2 k3 (AnsVar a) -> [((Int, Int), a)] Source #

toMatListT7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd a) => TensList7 k1 k2 k3 k4 (AnsVar a) -> [((Int, Int), a)] Source #

toMatListT8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd a) => TensList8 k1 k2 k3 k4 (AnsVar a) -> [((Int, Int), a)] Source #

Convert all Tensors of a heterogeneous tensor List to a combined HM.Matrix.

toMatrixT5 :: (TIndex k1, TIndex k2, TIndex k3, Real a) => TensList5 k1 k2 k3 (AnsVar (SField a)) -> Matrix Double Source #

toMatrixT6 :: (TIndex k1, TIndex k2, TIndex k3, Real a) => TensList6 k1 k2 k3 (AnsVar (SField a)) -> Matrix Double Source #

toMatrixT7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, Real a) => TensList7 k1 k2 k3 k4 (AnsVar (SField a)) -> Matrix Double Source #

toMatrixT8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, Real a) => TensList8 k1 k2 k3 k4 (AnsVar (SField a)) -> Matrix Double Source #

## Tensor utility functions

### Removing Zeros

removeZeros :: TAdd v => Tensor n k v -> Tensor n k v Source #

Applying these functions on a given tensor removes all zero values from it. Even if zero values are not included in a given tensor when it is constructed they might occur during computations. If so they are not automatically removed from the tensor.

The following functions allow the removal of zero values of Tensors with multiple different index types.

removeZeros1 :: (TAdd v, TIndex k) => AbsTensor1 n1 k v -> AbsTensor1 n1 k v Source #

 removeZeros1 = removeZeros

removeZeros2 :: (TAdd v, TIndex k) => AbsTensor2 n1 n2 k v -> AbsTensor2 n1 n2 k v Source #

removeZeros2 = removeZeros . mapTo1 removeZeros

removeZeros3 :: (TAdd v, TIndex k1, TIndex k2) => AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v Source #

removeZeros3 = removeZeros . mapTo1 removeZeros . mapTo2 removeZeros

removeZeros4 :: (TAdd v, TIndex k1, TIndex k2) => AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v Source #

removeZeros4 = removeZeros . mapTo1 removeZeros . mapTo2 removeZeros . mapTo3 removeZeros

removeZeros5 :: (TAdd v, TIndex k1, TIndex k2, TIndex k3) => AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v Source #

removeZeros5 = removeZeros . mapTo1 removeZeros . mapTo2 removeZeros . mapTo3 removeZeros . mapTo4 removeZeros

removeZeros6 :: (TAdd v, TIndex k1, TIndex k2, TIndex k3) => AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v Source #

removeZeros6 = removeZeros . mapTo1 removeZeros . mapTo2 removeZeros . mapTo3 removeZeros . mapTo4 removeZeros . mapTo5 removeZeros

removeZeros7 :: (TAdd v, TIndex k1, TIndex k2, TIndex k3, TIndex k4) => AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v Source #

removeZeros7 = removeZeros . mapTo1 removeZeros . mapTo2 removeZeros . mapTo3 removeZeros . mapTo4 removeZeros . mapTo5 removeZeros . mapTo6 removeZeros

removeZeros8 :: (TAdd v, TIndex k1, TIndex k2, TIndex k3, TIndex k4) => AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v Source #

removeZeros8 = removeZeros . mapTo1 removeZeros . mapTo2 removeZeros . mapTo3 removeZeros . mapTo4 removeZeros . mapTo5 removeZeros . mapTo6 removeZeros . mapTo7 removeZeros

### Evaluation

evalTens :: (KnownNat n, 1 <= n, TIndex k, TAdd v) => Int -> k -> Tensor n k v -> Tensor (n - 1) k v Source #

Evaluate a Tensor for a specific value of its first contravariant index type returning the corresponding sub Tensor. The additional functions specified below apply the evaluation function evalTens to the deeper Tensor levels.

The following functions can be used if the Tensor shall be evaluated for an index type that is different from the first index type of the Tensor.

evalTens1 :: (KnownNat n1, TIndex k1, TAdd v) => Int -> k1 -> AbsTensor1 (n1 + 1) k1 v -> AbsTensor1 n1 k1 v Source #

evalTens1 = evalTens

evalTens2 :: (KnownNat n2, TIndex k1, TAdd v) => Int -> k1 -> AbsTensor2 n1 (n2 + 1) k1 v -> AbsTensor2 n1 n2 k1 v Source #

evalTens2 ind indVal = mapTo1 (evalTens ind indVal)

evalTens3 :: (KnownNat n3, TIndex k1, TIndex k2, TAdd v) => Int -> k2 -> AbsTensor3 n1 n2 (n3 + 1) k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v Source #

evalTens3 ind indVal = mapTo2 (evalTens ind indVal)

evalTens4 :: (KnownNat n4, TIndex k1, TIndex k2, TAdd v) => Int -> k2 -> AbsTensor4 n1 n2 n3 (n4 + 1) k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v Source #

evalTens4 ind indVal = mapTo3 (evalTens ind indVal)

evalTens5 :: (KnownNat n5, TIndex k1, TIndex k2, TIndex k3, TAdd v) => Int -> k3 -> AbsTensor5 n1 n2 n3 n4 (n5 + 1) k1 k2 k3 v -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v Source #

evalTens5 ind indVal = mapTo4 (evalTens ind indVal)

evalTens6 :: (KnownNat n6, TIndex k1, TIndex k2, TIndex k3, TAdd v) => Int -> k3 -> AbsTensor6 n1 n2 n3 n4 n5 (n6 + 1) k1 k2 k3 v -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v Source #

evalTens6 ind indVal = mapTo5 (evalTens ind indVal)

evalTens7 :: (KnownNat n7, TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => Int -> k4 -> AbsTensor7 n1 n2 n3 n4 n5 n6 (n7 + 1) k1 k2 k3 k4 v -> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v Source #

evalTens7 ind indVal = mapTo6 (evalTens ind indVal)

evalTens8 :: (KnownNat n8, TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => Int -> k4 -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 (n8 + 1) k1 k2 k3 k4 v -> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v Source #

evalTens8 ind indVal = mapTo7 (evalTens ind indVal)

### Rank Computations

Compute the rank of a tensor of AnsVarR values. The tensor is converted to a matrix with columns labeling the individual variables that occur in ansVarR and rows labeling the independent tensor components. The rank is then computed using hmatrix subroutines. These functions is for instance useful when determining the rank of tensorial equations.

Compute the rank of a single Tensor.

tensorRank1' :: (TIndex k1, Real a, Real a) => AbsTensor1 n1 k1 (AnsVar (SField a)) -> Int Source #

tensorRank2' :: (TIndex k1, Real a) => AbsTensor2 n1 n2 k1 (AnsVar (SField a)) -> Int Source #

tensorRank3' :: (TIndex k1, TIndex k2, Real a) => AbsTensor3 n1 n2 n3 k1 k2 (AnsVar (SField a)) -> Int Source #

tensorRank4' :: (TIndex k1, TIndex k2, Real a) => AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar (SField a)) -> Int Source #

tensorRank5' :: (TIndex k1, TIndex k2, TIndex k3, Real a) => AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar (SField a)) -> Int Source #

tensorRank6' :: (TIndex k1, TIndex k2, TIndex k3, Real a) => AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar (SField a)) -> Int Source #

tensorRank7' :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, Real a) => AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar (SField a)) -> Int Source #

tensorRank8' :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, Real a) => AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar (SField a)) -> Int Source #

Compute the combined rank of a heterogeneous list of multiple tensors.

tensorRank3 :: (TIndex k1, TIndex k2, Real a) => TensList3 k1 k2 (AnsVar (SField a)) -> Int Source #

tensorRank4 :: (TIndex k1, TIndex k2, Real a) => TensList4 k1 k2 (AnsVar (SField a)) -> Int Source #

tensorRank5 :: (TIndex k1, TIndex k2, TIndex k3, Real a) => TensList5 k1 k2 k3 (AnsVar (SField a)) -> Int Source #

tensorRank6 :: (TIndex k1, TIndex k2, TIndex k3, Real a) => TensList6 k1 k2 k3 (AnsVar (SField a)) -> Int Source #

tensorRank7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, Real a) => TensList7 k1 k2 k3 k4 (AnsVar (SField a)) -> Int Source #

tensorRank8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, Real a) => TensList8 k1 k2 k3 k4 (AnsVar (SField a)) -> Int Source #

### Save and Load Tensors

encodeTensor :: (KnownNat n, Ord k, Serialize k, Serialize v) => Tensor n k v -> ByteString Source #

Utility function to serialize and compress a Tensor into a ByteString, making use of the Serialize instance.

decodeTensor :: (KnownNat n, Ord k, Serialize k, Serialize v) => ByteString -> Either String (Tensor n k v) Source #

Utility function to decompress and de-serialize a ByteString into a Tensor, making use of the Serialize instance.

## Tensor Differentiation

### Partial Derivatives

partial :: Num a => STTens n1 n2 (CFun [Forward a] (Forward a)) -> STTens n1 (n2 + 1) (CFun [a] a) Source #

The function computes partial derivatives of spacetime tensors of type STTens with CFun values.

partialSymbolic :: [String] -> STTens n1 n2 SSymbolic -> STTens n1 (n2 + 1) SSymbolic Source #

The function computes partial derivatives of spacetime tensors of type STTens with SSymbolic values.

g_ab_p = partialSymbolic ["t", "x", "y", "z"] g_ab