-----------------------------------------------------------------------------
-- |
-- Module      :  Math.Tensor
-- Copyright   :  (c) 2019 Tobias Reinhart and Nils Alex
-- License     :  MIT
-- Maintainer  :  tobi.reinhart@fau.de, nils.alex@fau.de
--
--
-- 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 @'Tensor'@s 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 @'Tensor'@s with the same type.
-- Unintentional additions of @'Tensor'@s 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 @'Tensor'@s only non zero values must be specified.
-- Missing values are then taken as vanishing automatically.
-----------------------------------------------------------------------------

{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE AllowAmbiguousTypes #-}

{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveAnyClass #-}

{-# LANGUAGE LambdaCase #-}

{-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver #-}
{-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise #-}
{-# OPTIONS_GHC -fplugin-opt GHC.TypeLits.Normalise:allow-negated-numbers #-}

module Math.Tensor (
-- * Tensor Data Types
-- ** Length Typed Index List
--
-- | @'Tensor'@s 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.
IndList(..),
--
singletonInd, (+>), fromList, fromListUnsafe,
headInd, tailInd, sortInd, updateInd,
-- ** 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.
--
TMap,
Tensor(..),
--
Tensor2,
--
-- | __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.__
AbsTensor1, AbsTensor2, AbsTensor3, AbsTensor4, AbsTensor5, AbsTensor6, AbsTensor7, AbsTensor8,
--
STTens, ATens,
--
-- ** Index Type Class
--
TIndex,
--
Ind3(..), Ind9(..), Ind20(..),
--
-- ** 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 @'Tensor'@s or represent simple scalar values.
--
TAdd(..),
--
Prod(..),
--
-- ** Tensor Value Instances
-- *** Scalar Values
--
SField(..),
--
-- *** Linear Variables
AnsVar(..), AnsVarR,
--
shiftVarLabels,
--
-- | __The following functions apply this shift of the variable labels, i.e. the function @'shiftVarLabels'@ to all @'AnsVar'@s that are contained in a @'Tensor'@.__
shiftLabels1, shiftLabels2, shiftLabels3, shiftLabels4, shiftLabels5, shiftLabels6, shiftLabels7, shiftLabels8,
--
-- *** Functions as Values
--
CFun(..), evalSec,
--
-- *** Symbolic Values
SSymbolic(..),
--
-- ** Construction of Tensor
-- | @'Tensor'@s can most easily be constructed from key value list where the keys are tuples of either @'IndList'@s 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 @'IndList'@s.
--
-- __The following are type synonyms that are frequently for these key value lists.__
IndTuple1, IndTuple2, IndTuple3, IndTuple4, IndTuple5, IndTuple6, IndTuple7, IndTuple8,
--
IndTupleST, IndTupleAbs,
--
fromListT,
--
-- | __The following functions employ the construction of different @'Tensor'@ types from such typed key value lists.__
fromListT1, fromListT2, fromListT3, fromListT4, fromListT5, fromListT6, fromListT7, fromListT8,
--
fromListT',
--
-- | __The following functions employ the construction of different @'Tensor'@ types from un-typed key value lists.__
fromListT1', fromListT2', fromListT3', fromListT4', fromListT5', fromListT6', fromListT7', fromListT8',
--
-- ** Accessing Deeper Leaf Levels
-- | Given @'Tensor'@s with multiple index types, i.e. @'Tensor'@s that themselves have further @'Tensor'@s attached as their leafs, i.e. as their @'Scalar'@s 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 @'Tensor'@s as arguments to be applied to @'Tensor'@s that are attached in deeper levels.
--
mapTo1, mapTo2, mapTo3, mapTo4, mapTo5, mapTo6, mapTo7, mapTo8,
--
-- * Tensor Algebra
--
-- ** Basic Tensor Algebra Operations
--
-- | The following functions provide the @'Tensor'@ type with the structure of the usual tensor algebra.
(&+), negateTens, (&*), (&-), (&.),
--
--
tensorContr,
--
-- | __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, contrATens2, contrATens3, contrATens4,
--
-- ** Rearranging indices
--
-- *** Swapping 2 Indices
tensorTrans,
--
-- | __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, tensorTrans2, tensorTrans3, tensorTrans4, tensorTrans5, tensorTrans6, tensorTrans7, tensorTrans8,
--
-- *** Swapping 2 index Blocks
tensorBlockTrans,
--
-- | __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, tensorBlockTrans2, tensorBlockTrans3, tensorBlockTrans4, tensorBlockTrans5, tensorBlockTrans6, tensorBlockTrans7, tensorBlockTrans8,
--
-- *** Permuting indices
resortTens,
--
-- | __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, resortTens2, resortTens3, resortTens4, resortTens5, resortTens6, resortTens7, resortTens8,
--
-- ** Symmetrization of Tensors
--
-- *** Pair Symmetrization
symTens,
--
-- | __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, symATens2, symATens3, symATens4, symATens5, symATens6, symATens7, symATens8,
--
symTensFac,
--
-- | __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, symATensFac2, symATensFac3, symATensFac4, symATensFac5, symATensFac6, symATensFac7, symATensFac8,
--
-- *** Pair Anti Symmetrization
aSymTens,
--
-- | __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, aSymATens2, aSymATens3, aSymATens4, aSymATens5, aSymATens6, aSymATens7, aSymATens8,
--
aSymTensFac,
--
-- | __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, aSymATensFac2, aSymATensFac3, aSymATensFac4, aSymATensFac5, aSymATensFac6, aSymATensFac7, aSymATensFac8,
--
-- *** Block Exchange Symmetrization
symBlockTens,
--
-- | __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, symBlockATens2, symBlockATens3, symBlockATens4, symBlockATens5, symBlockATens6, symBlockATens7, symBlockATens8,
--
symBlockTensFac,
--
-- | __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, symBlockATensFac2, symBlockATensFac3, symBlockATensFac4, symBlockATensFac5, symBlockATensFac6, symBlockATensFac7, symBlockATensFac8,
--
-- *** Block Exchange Anti Symmetrization
aSymBlockTens,
--
-- | __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, aSymBlockATens2, aSymBlockATens3, aSymBlockATens4, aSymBlockATens5, aSymBlockATens6, aSymBlockATens7, aSymBlockATens8,
--
aSymBlockTensFac,
--
-- | __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, aSymBlockATensFac2, aSymBlockATensFac3, aSymBlockATensFac4, aSymBlockATensFac5, aSymBlockATensFac6, aSymBlockATensFac7, aSymBlockATensFac8,
--
-- *** Cyclic Symmetrization
cyclicSymTens,
--
-- | __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, cyclicSymATens2, cyclicSymATens3, cyclicSymATens4, cyclicSymATens5, cyclicSymATens6, cyclicSymATens7, cyclicSymATens8,
--
cyclicSymTensFac,
--
-- | __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, cyclicSymATensFac2, cyclicSymATensFac3, cyclicSymATensFac4, cyclicSymATensFac5, cyclicSymATensFac6, cyclicSymATensFac7, cyclicSymATensFac8,
--
-- *** Cyclic Anti Symmetrization
cyclicASymTens,
--
-- | __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, cyclicASymATens2, cyclicASymATens3, cyclicASymATens4, cyclicASymATens5, cyclicASymATens6, cyclicASymATens7, cyclicASymATens8,
--
cyclicASymTensFac,
--
-- | __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, cyclicASymATensFac2, cyclicASymATensFac3, cyclicASymATensFac4, cyclicASymATensFac5, cyclicASymATensFac6, cyclicASymATensFac7, cyclicASymATensFac8,
--
-- *** Cyclic Block Symmetrization
cyclicBlockSymTens,
--
-- | __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, cyclicBlockSymATens2, cyclicBlockSymATens3, cyclicBlockSymATens4, cyclicBlockSymATens5, cyclicBlockSymATens6, cyclicBlockSymATens7, cyclicBlockSymATens8,
--
cyclicBlockSymTensFac,
--
-- | __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, cyclicBlockSymATensFac2, cyclicBlockSymATensFac3, cyclicBlockSymATensFac4, cyclicBlockSymATensFac5, cyclicBlockSymATensFac6, cyclicBlockSymATensFac7, cyclicBlockSymATensFac8,
--
-- * Tensor Functions
-- ** Lists of multiple Tensors
--
-- | Sometimes it is convenient to collect multiple @'Tensors'@s with the same value type. To allow the individual @'Tensor'@s to have different rank these lists are heterogeneous.
TensList1(..), TensList2(..), TensList3(..), TensList4(..), TensList5(..), TensList6(..), TensList7(..), TensList8(..),
--
-- | __Construction of a such heterogeneous list with a single @'Tensor'@ as Entry.__
singletonTList1, singletonTList2, singletonTList3, singletonTList4, singletonTList5, singletonTList6, singletonTList7, singletonTList8,
--
-- | __Infix Synonyms for the various constructors such as @'AppendTList1'@, @'AppendTList2'@, etc.__
(...>), (..&>), (.&.>), (.&&>), (&..>), (&.&>), (&&.>), (&&&>),
--
-- | __Combining functions for the separate heterogeneous tensor lists.__
(...+), (..&+), (.&.+), (.&&+), (&..+), (&.&+), (&&.+), (&&&+),
--
-- ** Conversion of Tensors
-- *** To List
--
toListT,
--
-- | __Converting the various @'Tensors'@ with multiple different index types to such typed lists.__
toListT1, toListT2, toListT3, toListT4, toListT5, toListT6, toListT7, toListT8,
--
toListT',
--
-- | __Converting the various @'Tensors'@ with multiple different index types to such non-typed lists.__
toListT1', toListT2', toListT3', toListT4', toListT5', toListT6', toListT7', toListT8',
--
-- *** 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', toMatListT2', toMatListT3', toMatListT4', toMatListT5', toMatListT6', toMatListT7', toMatListT8',
--
-- __ Convert a @'Tensor'@ to a "HM.Matrix".__
toMatrixT1', toMatrixT2', toMatrixT3', toMatrixT4', toMatrixT5', toMatrixT6', toMatrixT7', toMatrixT8',
--
-- | __ Convert all @'Tensors'@ of a heterogeneous tensor List to a combined sparse matrix assocs list.__
toMatListT1, toMatListT2, toMatListT3, toMatListT4, toMatListT5, toMatListT6, toMatListT7, toMatListT8,
--
-- | __ Convert all @'Tensors'@ of a heterogeneous tensor List to a combined "HM.Matrix".__
toMatrixT1, toMatrixT2, toMatrixT3, toMatrixT4, toMatrixT5, toMatrixT6, toMatrixT7, toMatrixT8,
--
-- ** Tensor utility functions
--
-- *** Removing Zeros
removeZeros,
--
-- | __The following functions allow the removal of zero values of @'Tensor'@s with multiple different index types.__
removeZeros1, removeZeros2, removeZeros3, removeZeros4, removeZeros5, removeZeros6, removeZeros7, removeZeros8,
--
-- *** Evaluation
evalTens,
--
-- | __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, evalTens2, evalTens3, evalTens4, evalTens5, evalTens6, evalTens7, evalTens8,
--
-- *** 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', tensorRank2', tensorRank3', tensorRank4', tensorRank5', tensorRank6', tensorRank7', tensorRank8',
--
-- | __Compute the combined rank of a heterogeneous list of multiple tensors.__
tensorRank1, tensorRank2, tensorRank3, tensorRank4, tensorRank5, tensorRank6, tensorRank7, tensorRank8,
--
-- *** Save and Load Tensors
encodeTensor, decodeTensor,
--
-- ** Tensor Differentiation
-- *** Partial Derivatives
partial, partialSymbolic
) where

import Data.Foldable (toList)
import Control.Applicative (liftA2)
import Data.List (sortOn, intersect)
import Data.Maybe (mapMaybe, fromMaybe)
import Data.Proxy
import Data.Type.Equality
import qualified Data.IntMap.Strict as I
import Numeric.Natural (Natural)
import qualified Numeric.AD.Rank1.Forward as AD
import GHC.TypeLits
import GHC.Generics (Generic(..))
import Control.DeepSeq (rnf, NFData(..))
import Data.Serialize (encodeLazy, decodeLazy, Serialize(..))
import Unsafe.Coerce (unsafeCoerce)
import qualified Data.ByteString.Lazy as BS (ByteString)
import Codec.Compression.GZip (compress, decompress)

--for Linear Algebra subroutines
import qualified Numeric.LinearAlgebra.Data as HM
import Numeric.LinearAlgebra (rank)

--Length typed lists for the tensor indices.

data IndList n a where
    Empty :: IndList 0 a
    Append :: a -> IndList (n-1) a -> IndList n a

infixr 5 +>

-- | Infix synonym for @'Append'@.

(+>) :: Enum a => Int -> IndList (n-1) a -> IndList n a
+> :: Int -> IndList (n - 1) a -> IndList n a
(+>) Int
i = a -> IndList (n - 1) a -> IndList n a
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
Append (Int -> a
forall a. Enum a => Int -> a
toEnum Int
i)

-- | Construct an @'IndList'@ that only contains a single value.

singletonInd :: a -> IndList 1 a
singletonInd :: a -> IndList 1 a
singletonInd a
x = a -> IndList (1 - 1) a -> IndList 1 a
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
Append a
x IndList (1 - 1) a
forall a. IndList 0 a
Empty

--Helper functions for the construction from untyped lists.

data IsZero (n :: Nat) where
    Zero :: (0 ~ n)     => IsZero n
    NonZero :: (1 <= n) => IsZero n
deriving instance Show (IsZero n)

isZero :: forall n. KnownNat n => Proxy n -> IsZero n
isZero :: Proxy n -> IsZero n
isZero Proxy n
_ = case Proxy n -> Proxy 0 -> Maybe (n :~: 0)
forall (a :: Nat) (b :: Nat).
(KnownNat a, KnownNat b) =>
Proxy a -> Proxy b -> Maybe (a :~: b)
sameNat (Proxy n
forall k (t :: k). Proxy t
Proxy @n) (Proxy 0
forall k (t :: k). Proxy t
Proxy @0)
             of Maybe (n :~: 0)
Nothing   -> IsZero 1 -> IsZero n
forall a b. a -> b
unsafeCoerce ((1 <= 1) => IsZero 1
forall (n :: Nat). (1 <= n) => IsZero n
NonZero @1)
                Just n :~: 0
Refl -> IsZero n
forall (n :: Nat). (0 ~ n) => IsZero n
Zero

isZero' :: forall n. KnownNat n => IsZero n
isZero' :: IsZero n
isZero' = case Proxy n -> Proxy 0 -> Maybe (n :~: 0)
forall (a :: Nat) (b :: Nat).
(KnownNat a, KnownNat b) =>
Proxy a -> Proxy b -> Maybe (a :~: b)
sameNat (Proxy n
forall k (t :: k). Proxy t
Proxy @n) (Proxy 0
forall k (t :: k). Proxy t
Proxy @0)
            of Maybe (n :~: 0)
Nothing   -> IsZero 1 -> IsZero n
forall a b. a -> b
unsafeCoerce ((1 <= 1) => IsZero 1
forall (n :: Nat). (1 <= n) => IsZero n
NonZero @1)
               Just n :~: 0
Refl -> IsZero n
forall (n :: Nat). (0 ~ n) => IsZero n
Zero

-- | Construction of a length typed @'IndList'@ from an untyped list.

fromList :: forall n. KnownNat n => forall (a :: *). [a] -> Maybe (IndList n a)
fromList :: forall a. [a] -> Maybe (IndList n a)
fromList [a]
xs = case KnownNat n => IsZero n
forall (n :: Nat). KnownNat n => IsZero n
isZero' @n
                of IsZero n
Zero    -> case [a]
xs
                                of [] -> IndList 0 a -> Maybe (IndList 0 a)
forall a. a -> Maybe a
Just IndList 0 a
forall a. IndList 0 a
Empty
                                   [a]
_  -> Maybe (IndList n a)
forall a. Maybe a
Nothing
                   IsZero n
NonZero -> case [a]
xs
                                of []    -> Maybe (IndList n a)
forall a. Maybe a
Nothing
                                   a
x:[a]
xs' -> case [a] -> Maybe (IndList (n - 1) a)
forall (n :: Nat) a. KnownNat n => [a] -> Maybe (IndList n a)
fromList [a]
xs'
                                              of Just IndList (n - 1) a
v  -> IndList n a -> Maybe (IndList n a)
forall a. a -> Maybe a
Just (a
x a -> IndList (n - 1) a -> IndList n a
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
`Append` IndList (n - 1) a
v)
                                                 Maybe (IndList (n - 1) a)
Nothing -> Maybe (IndList n a)
forall a. Maybe a
Nothing

-- | Construction of a length typed @'IndList'@ (partial function).

fromListUnsafe :: forall n.KnownNat n => forall (a :: *). [a] -> IndList n a
fromListUnsafe :: forall a. [a] -> IndList n a
fromListUnsafe [a]
xs = IndList n a -> Maybe (IndList n a) -> IndList n a
forall a. a -> Maybe a -> a
fromMaybe (String -> IndList n a
forall a. HasCallStack => String -> a
error String
errorString) ([a] -> Maybe (IndList n a)
forall (n :: Nat) a. KnownNat n => [a] -> Maybe (IndList n a)
fromList [a]
xs)
  where
    nVal :: Integer
nVal = Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall a. HasCallStack => a
undefined :: Proxy n)
    len :: Int
len = [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
xs
    errorString :: String
errorString = String
"Could not construct IndList " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Integer -> String
forall a. Show a => a -> String
show Integer
nVal String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" from " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
len String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" elements."

--Instances of the length typed lists.

instance (KnownNat n, Generic a) => Generic (IndList n a) where
    type Rep (IndList n a) = Rep [a]

    to :: Rep (IndList n a) x -> IndList n a
to Rep (IndList n a) x
r = [a] -> IndList n a
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe ([a] -> IndList n a) -> [a] -> IndList n a
forall a b. (a -> b) -> a -> b
$ Rep [a] x -> [a]
forall a x. Generic a => Rep a x -> a
to Rep [a] x
Rep (IndList n a) x
r
    from :: IndList n a -> Rep (IndList n a) x
from = [a]
-> D1
     ('MetaData "[]" "GHC.Types" "ghc-prim" 'False)
     (C1 ('MetaCons "[]" 'PrefixI 'False) U1
      :+: C1
            ('MetaCons ":" ('InfixI 'LeftAssociative 9) 'False)
            (S1
               ('MetaSel
                  'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
               (Rec0 a)
             :*: S1
                   ('MetaSel
                      'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                   (Rec0 [a])))
     x
forall a x. Generic a => a -> Rep a x
from ([a]
 -> D1
      ('MetaData "[]" "GHC.Types" "ghc-prim" 'False)
      (C1 ('MetaCons "[]" 'PrefixI 'False) U1
       :+: C1
             ('MetaCons ":" ('InfixI 'LeftAssociative 9) 'False)
             (S1
                ('MetaSel
                   'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                (Rec0 a)
              :*: S1
                    ('MetaSel
                       'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                    (Rec0 [a])))
      x)
-> (IndList n a -> [a])
-> IndList n a
-> D1
     ('MetaData "[]" "GHC.Types" "ghc-prim" 'False)
     (C1 ('MetaCons "[]" 'PrefixI 'False) U1
      :+: C1
            ('MetaCons ":" ('InfixI 'LeftAssociative 9) 'False)
            (S1
               ('MetaSel
                  'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
               (Rec0 a)
             :*: S1
                   ('MetaSel
                      'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                   (Rec0 [a])))
     x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IndList n a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList

deriving instance (KnownNat n, Generic a, Serialize a) => Serialize (IndList n a)

instance (NFData a) => NFData (IndList n a) where
    rnf :: IndList n a -> ()
rnf IndList n a
Empty = ()
    rnf (Append a
a IndList (n - 1) a
i) = a -> ()
forall a. NFData a => a -> ()
rnf a
a () -> () -> ()
`seq` IndList (n - 1) a -> ()
forall a. NFData a => a -> ()
rnf IndList (n - 1) a
i

deriving instance (Eq a) => Eq (IndList n a)

deriving instance (Ord a) => Ord (IndList n a)

deriving instance (Show a) => Show (IndList n a)

instance Functor (IndList n) where
    fmap :: (a -> b) -> IndList n a -> IndList n b
fmap a -> b
_ IndList n a
Empty = IndList n b
forall a. IndList 0 a
Empty
    fmap a -> b
f (Append a
x IndList (n - 1) a
xs) = b -> IndList (n - 1) b -> IndList n b
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
Append (a -> b
f a
x) ((a -> b) -> IndList (n - 1) a -> IndList (n - 1) b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f IndList (n - 1) a
xs)

instance Foldable (IndList n) where
    foldr :: (a -> b -> b) -> b -> IndList n a -> b
foldr a -> b -> b
_ b
y IndList n a
Empty = b
y
    foldr a -> b -> b
f b
y (Append a
x IndList (n - 1) a
xs) = a -> b -> b
f a
x ((a -> b -> b) -> b -> IndList (n - 1) a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr a -> b -> b
f b
y IndList (n - 1) a
xs)

--list operations on length typed lists

insertSorted :: (Ord a, Eq a) => a -> IndList n a -> IndList (n+1) a
insertSorted :: a -> IndList n a -> IndList (n + 1) a
insertSorted a
y IndList n a
Empty = a -> IndList (1 - 1) a -> IndList 1 a
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
Append a
y IndList (1 - 1) a
forall a. IndList 0 a
Empty
insertSorted a
y (Append a
x IndList (n - 1) a
xs)
    | a
y a -> a -> Bool
forall a. Ord a => a -> a -> Bool
<= a
x = a -> IndList ((n + 1) - 1) a -> IndList (n + 1) a
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
Append a
y (IndList ((n + 1) - 1) a -> IndList (n + 1) a)
-> IndList ((n + 1) - 1) a -> IndList (n + 1) a
forall a b. (a -> b) -> a -> b
$ a -> IndList (n - 1) a -> IndList n a
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
Append a
x IndList (n - 1) a
xs
    | Bool
otherwise = a -> IndList ((n + 1) - 1) a -> IndList (n + 1) a
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
Append a
x (IndList ((n + 1) - 1) a -> IndList (n + 1) a)
-> IndList ((n + 1) - 1) a -> IndList (n + 1) a
forall a b. (a -> b) -> a -> b
$ a -> IndList (n - 1) a -> IndList ((n - 1) + 1) a
forall a (n :: Nat).
(Ord a, Eq a) =>
a -> IndList n a -> IndList (n + 1) a
insertSorted a
y IndList (n - 1) a
xs

-- | Sorts an @'IndList'@ of elements that satisfy the @'Ord'@ constraint by implementing a version of insertion sort.

sortInd :: (Ord a, Eq a) => IndList n a -> IndList n a
sortInd :: IndList n a -> IndList n a
sortInd IndList n a
Empty = IndList n a
forall a. IndList 0 a
Empty
sortInd (Append a
x IndList (n - 1) a
xs) = a -> IndList (n - 1) a -> IndList ((n - 1) + 1) a
forall a (n :: Nat).
(Ord a, Eq a) =>
a -> IndList n a -> IndList (n + 1) a
insertSorted a
x (IndList (n - 1) a -> IndList ((n - 1) + 1) a)
-> IndList (n - 1) a -> IndList ((n - 1) + 1) a
forall a b. (a -> b) -> a -> b
$ IndList (n - 1) a -> IndList (n - 1) a
forall a (n :: Nat). (Ord a, Eq a) => IndList n a -> IndList n a
sortInd IndList (n - 1) a
xs

-- | An implementation of the usual head function from "Data.List" for @'IndList'@s. The function returns the first element of the @'IndList'@.

headInd :: IndList n a -> a
headInd :: IndList n a -> a
headInd IndList n a
Empty = String -> a
forall a. HasCallStack => String -> a
error String
"head of empty IndList"
headInd (Append a
x IndList (n - 1) a
_) = a
x

-- | An implementation of the usual tail function from "Data.List" for @'IndList'@s. The function removes the first element of the @'IndList'@.

tailInd :: IndList n a -> IndList (n-1) a
tailInd :: IndList n a -> IndList (n - 1) a
tailInd IndList n a
Empty = String -> IndList (0 - 1) a
forall a. HasCallStack => String -> a
error String
"tail of empty IndList"
tailInd (Append a
_ IndList (n - 1) a
xs) = IndList (n - 1) a
xs

-- | An implementation of the usual @(!!)@ function from "Data.List" for @'IndList'@s. The function returns the list element that is specified by the provided integer value.
--  Indices start from zero.

indexInd :: Int -> IndList n a -> a
indexInd :: Int -> IndList n a -> a
indexInd Int
0 (Append a
x IndList (n - 1) a
_) = a
x
indexInd Int
i (Append a
_ IndList (n - 1) a
xs) = Int -> IndList (n - 1) a -> a
forall (n :: Nat) a. Int -> IndList n a -> a
indexInd (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) IndList (n - 1) a
xs
indexInd Int
_ IndList n a
_ = String -> a
forall a. HasCallStack => String -> a
error String
"Index is too large!"

-- | The function replaces the element at index/position specified by its first argument with the element that is specified by its second argument.

updateInd :: Int -> a -> IndList n a -> IndList n a
updateInd :: Int -> a -> IndList n a -> IndList n a
updateInd Int
0 a
s (Append a
_ IndList (n - 1) a
xs) = a -> IndList (n - 1) a -> IndList n a
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
Append a
s IndList (n - 1) a
xs
updateInd Int
i a
s (Append a
x IndList (n - 1) a
xs) = a -> IndList (n - 1) a -> IndList n a
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
Append a
x (IndList (n - 1) a -> IndList n a)
-> IndList (n - 1) a -> IndList n a
forall a b. (a -> b) -> a -> b
$ Int -> a -> IndList (n - 1) a -> IndList (n - 1) a
forall a (n :: Nat). Int -> a -> IndList n a -> IndList n a
updateInd (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) a
s IndList (n - 1) a
xs
updateInd Int
_ a
_  IndList n a
_ = String -> IndList n a
forall a. HasCallStack => String -> a
error String
"Index is too large!"

-- Special functions for the contraction of tensors.

swapHead :: Int -> IndList n b -> IndList n b
swapHead :: Int -> IndList n b -> IndList n b
swapHead Int
1 (Append b
x IndList (n - 1) b
xs) = b -> IndList (n - 1) b -> IndList n b
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
Append (IndList (n - 1) b -> b
forall (n :: Nat) a. IndList n a -> a
headInd IndList (n - 1) b
xs) (IndList (n - 1) b -> IndList n b)
-> IndList (n - 1) b -> IndList n b
forall a b. (a -> b) -> a -> b
$ b -> IndList ((n - 1) - 1) b -> IndList (n - 1) b
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
Append b
x (IndList (n - 1) b -> IndList ((n - 1) - 1) b
forall (n :: Nat) a. IndList n a -> IndList (n - 1) a
tailInd IndList (n - 1) b
xs)
swapHead Int
i (Append b
x IndList (n - 1) b
xs) = b -> IndList (n - 1) b -> IndList n b
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
Append b
val IndList (n - 1) b
newL
    where
        val :: b
val = Int -> IndList (n - 1) b -> b
forall (n :: Nat) a. Int -> IndList n a -> a
indexInd (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) IndList (n - 1) b
xs
        newL :: IndList (n - 1) b
newL = Int -> b -> IndList (n - 1) b -> IndList (n - 1) b
forall a (n :: Nat). Int -> a -> IndList n a -> IndList n a
updateInd (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) b
x IndList (n - 1) b
xs
swapHead Int
_ IndList n b
Empty = String -> IndList n b
forall a. HasCallStack => String -> a
error String
"cannot swap head of empty list"

removeContractionInd :: (Eq a) => Int -> a -> (IndList n a, c) -> Maybe (IndList (n-1) a,c)
removeContractionInd :: Int -> a -> (IndList n a, c) -> Maybe (IndList (n - 1) a, c)
removeContractionInd Int
0 a
ind1 (Append a
x IndList (n - 1) a
xs, c
t)
        | a
ind1 a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
x = (IndList (n - 1) a, c) -> Maybe (IndList (n - 1) a, c)
forall a. a -> Maybe a
Just (IndList (n - 1) a
xs,c
t)
        | Bool
otherwise = Maybe (IndList (n - 1) a, c)
forall a. Maybe a
Nothing
removeContractionInd Int
i a
ind1 (Append a
x IndList (n - 1) a
xs,c
t) = (\(IndList ((n - 1) - 1) a
m,c
n) -> (a -> IndList ((n - 1) - 1) a -> IndList (n - 1) a
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
Append a
x IndList ((n - 1) - 1) a
m, c
n)) ((IndList ((n - 1) - 1) a, c) -> (IndList (n - 1) a, c))
-> Maybe (IndList ((n - 1) - 1) a, c)
-> Maybe (IndList (n - 1) a, c)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int
-> a
-> (IndList (n - 1) a, c)
-> Maybe (IndList ((n - 1) - 1) a, c)
forall a (n :: Nat) c.
Eq a =>
Int -> a -> (IndList n a, c) -> Maybe (IndList (n - 1) a, c)
removeContractionInd (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) a
ind1 (IndList (n - 1) a
xs,c
t)
removeContractionInd Int
_ a
_ (IndList n a
Empty, c
_) = String -> Maybe (IndList (0 - 1) a, c)
forall a. HasCallStack => String -> a
error String
"cannot remove index from empty index list"

{--
resort Inds in IndList according to the permutation given by [Int], length of [Int] must be n
example: perm = [1, 2, 0] -> "C is put on 0th pos. A on 1st and B on 2nd"
         indList = [A, B, C]
         algorithm sorts [(1,A), (2,B), (0,C)] on firsts
         => [(0,C), (1,A), (2,B)]
         => [C, A, B]
--}

resortInd :: (KnownNat n, Ord a) => [Int] -> IndList n a -> IndList n a
resortInd :: [Int] -> IndList n a -> IndList n a
resortInd [Int]
perm IndList n a
indList = IndList n a
newindList
    where
        l' :: [a]
l' = IndList n a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList IndList n a
indList
        l'' :: [(Int, a)]
l'' = if [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
l' Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== [Int] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Int]
perm then [Int] -> [a] -> [(Int, a)]
forall a b. [a] -> [b] -> [(a, b)]
zip [Int]
perm [a]
l' else String -> [(Int, a)]
forall a. HasCallStack => String -> a
error String
"permutation has wrong length"
        lReSorted :: [(Int, a)]
lReSorted = ((Int, a) -> Int) -> [(Int, a)] -> [(Int, a)]
forall b a. Ord b => (a -> b) -> [a] -> [a]
sortOn (Int, a) -> Int
forall a b. (a, b) -> a
fst [(Int, a)]
l''
        newindList :: IndList n a
newindList = [a] -> IndList n a
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe ([a] -> IndList n a) -> [a] -> IndList n a
forall a b. (a -> b) -> a -> b
$ ((Int, a) -> a) -> [(Int, a)] -> [a]
forall a b. (a -> b) -> [a] -> [b]
map (Int, a) -> a
forall a b. (a, b) -> b
snd [(Int, a)]
lReSorted

--Index type class

-- | The @'TIndex'@ type class collects a number of class constraints that any index type must satisfy.
class (Eq a, Ord a, Enum a) => TIndex a where

-- | Newtype wrapper for an index type that is used to represent indices with a range from @0@ to @3@.
newtype Ind3 =  Ind3 {Ind3 -> Int
indVal3 :: Int}
    deriving (Eq Ind3
Eq Ind3
-> (Ind3 -> Ind3 -> Ordering)
-> (Ind3 -> Ind3 -> Bool)
-> (Ind3 -> Ind3 -> Bool)
-> (Ind3 -> Ind3 -> Bool)
-> (Ind3 -> Ind3 -> Bool)
-> (Ind3 -> Ind3 -> Ind3)
-> (Ind3 -> Ind3 -> Ind3)
-> Ord Ind3
Ind3 -> Ind3 -> Bool
Ind3 -> Ind3 -> Ordering
Ind3 -> Ind3 -> Ind3
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Ind3 -> Ind3 -> Ind3
$cmin :: Ind3 -> Ind3 -> Ind3
max :: Ind3 -> Ind3 -> Ind3
$cmax :: Ind3 -> Ind3 -> Ind3
>= :: Ind3 -> Ind3 -> Bool
$c>= :: Ind3 -> Ind3 -> Bool
> :: Ind3 -> Ind3 -> Bool
$c> :: Ind3 -> Ind3 -> Bool
<= :: Ind3 -> Ind3 -> Bool
$c<= :: Ind3 -> Ind3 -> Bool
< :: Ind3 -> Ind3 -> Bool
$c< :: Ind3 -> Ind3 -> Bool
compare :: Ind3 -> Ind3 -> Ordering
$ccompare :: Ind3 -> Ind3 -> Ordering
$cp1Ord :: Eq Ind3
Ord, Ind3 -> Ind3 -> Bool
(Ind3 -> Ind3 -> Bool) -> (Ind3 -> Ind3 -> Bool) -> Eq Ind3
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Ind3 -> Ind3 -> Bool
$c/= :: Ind3 -> Ind3 -> Bool
== :: Ind3 -> Ind3 -> Bool
$c== :: Ind3 -> Ind3 -> Bool
Eq, Int -> Ind3 -> ShowS
[Ind3] -> ShowS
Ind3 -> String
(Int -> Ind3 -> ShowS)
-> (Ind3 -> String) -> ([Ind3] -> ShowS) -> Show Ind3
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Ind3] -> ShowS
$cshowList :: [Ind3] -> ShowS
show :: Ind3 -> String
$cshow :: Ind3 -> String
showsPrec :: Int -> Ind3 -> ShowS
$cshowsPrec :: Int -> Ind3 -> ShowS
Show, ReadPrec [Ind3]
ReadPrec Ind3
Int -> ReadS Ind3
ReadS [Ind3]
(Int -> ReadS Ind3)
-> ReadS [Ind3] -> ReadPrec Ind3 -> ReadPrec [Ind3] -> Read Ind3
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Ind3]
$creadListPrec :: ReadPrec [Ind3]
readPrec :: ReadPrec Ind3
$creadPrec :: ReadPrec Ind3
readList :: ReadS [Ind3]
$creadList :: ReadS [Ind3]
readsPrec :: Int -> ReadS Ind3
$creadsPrec :: Int -> ReadS Ind3
Read, (forall x. Ind3 -> Rep Ind3 x)
-> (forall x. Rep Ind3 x -> Ind3) -> Generic Ind3
forall x. Rep Ind3 x -> Ind3
forall x. Ind3 -> Rep Ind3 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Ind3 x -> Ind3
$cfrom :: forall x. Ind3 -> Rep Ind3 x
Generic, Ind3 -> ()
(Ind3 -> ()) -> NFData Ind3
forall a. (a -> ()) -> NFData a
rnf :: Ind3 -> ()
$crnf :: Ind3 -> ()
NFData, Get Ind3
Putter Ind3
Putter Ind3 -> Get Ind3 -> Serialize Ind3
forall t. Putter t -> Get t -> Serialize t
get :: Get Ind3
$cget :: Get Ind3
put :: Putter Ind3
$cput :: Putter Ind3
Serialize)

instance TIndex Ind3 where

instance Enum Ind3 where
    toEnum :: Int -> Ind3
toEnum = Int -> Ind3
Ind3
    fromEnum :: Ind3 -> Int
fromEnum = Ind3 -> Int
indVal3

-- | Newtype wrapper for an index type that is used to represent indices with a range from @0@ to @9@.
newtype Ind9 =  Ind9 {Ind9 -> Int
indVal9 :: Int}
    deriving (Eq Ind9
Eq Ind9
-> (Ind9 -> Ind9 -> Ordering)
-> (Ind9 -> Ind9 -> Bool)
-> (Ind9 -> Ind9 -> Bool)
-> (Ind9 -> Ind9 -> Bool)
-> (Ind9 -> Ind9 -> Bool)
-> (Ind9 -> Ind9 -> Ind9)
-> (Ind9 -> Ind9 -> Ind9)
-> Ord Ind9
Ind9 -> Ind9 -> Bool
Ind9 -> Ind9 -> Ordering
Ind9 -> Ind9 -> Ind9
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Ind9 -> Ind9 -> Ind9
$cmin :: Ind9 -> Ind9 -> Ind9
max :: Ind9 -> Ind9 -> Ind9
$cmax :: Ind9 -> Ind9 -> Ind9
>= :: Ind9 -> Ind9 -> Bool
$c>= :: Ind9 -> Ind9 -> Bool
> :: Ind9 -> Ind9 -> Bool
$c> :: Ind9 -> Ind9 -> Bool
<= :: Ind9 -> Ind9 -> Bool
$c<= :: Ind9 -> Ind9 -> Bool
< :: Ind9 -> Ind9 -> Bool
$c< :: Ind9 -> Ind9 -> Bool
compare :: Ind9 -> Ind9 -> Ordering
$ccompare :: Ind9 -> Ind9 -> Ordering
$cp1Ord :: Eq Ind9
Ord, Ind9 -> Ind9 -> Bool
(Ind9 -> Ind9 -> Bool) -> (Ind9 -> Ind9 -> Bool) -> Eq Ind9
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Ind9 -> Ind9 -> Bool
$c/= :: Ind9 -> Ind9 -> Bool
== :: Ind9 -> Ind9 -> Bool
$c== :: Ind9 -> Ind9 -> Bool
Eq, Int -> Ind9 -> ShowS
[Ind9] -> ShowS
Ind9 -> String
(Int -> Ind9 -> ShowS)
-> (Ind9 -> String) -> ([Ind9] -> ShowS) -> Show Ind9
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Ind9] -> ShowS
$cshowList :: [Ind9] -> ShowS
show :: Ind9 -> String
$cshow :: Ind9 -> String
showsPrec :: Int -> Ind9 -> ShowS
$cshowsPrec :: Int -> Ind9 -> ShowS
Show, ReadPrec [Ind9]
ReadPrec Ind9
Int -> ReadS Ind9
ReadS [Ind9]
(Int -> ReadS Ind9)
-> ReadS [Ind9] -> ReadPrec Ind9 -> ReadPrec [Ind9] -> Read Ind9
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Ind9]
$creadListPrec :: ReadPrec [Ind9]
readPrec :: ReadPrec Ind9
$creadPrec :: ReadPrec Ind9
readList :: ReadS [Ind9]
$creadList :: ReadS [Ind9]
readsPrec :: Int -> ReadS Ind9
$creadsPrec :: Int -> ReadS Ind9
Read, (forall x. Ind9 -> Rep Ind9 x)
-> (forall x. Rep Ind9 x -> Ind9) -> Generic Ind9
forall x. Rep Ind9 x -> Ind9
forall x. Ind9 -> Rep Ind9 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Ind9 x -> Ind9
$cfrom :: forall x. Ind9 -> Rep Ind9 x
Generic, Ind9 -> ()
(Ind9 -> ()) -> NFData Ind9
forall a. (a -> ()) -> NFData a
rnf :: Ind9 -> ()
$crnf :: Ind9 -> ()
NFData, Get Ind9
Putter Ind9
Putter Ind9 -> Get Ind9 -> Serialize Ind9
forall t. Putter t -> Get t -> Serialize t
get :: Get Ind9
$cget :: Get Ind9
put :: Putter Ind9
$cput :: Putter Ind9
Serialize)

instance TIndex Ind9 where

instance Enum Ind9 where
        toEnum :: Int -> Ind9
toEnum = Int -> Ind9
Ind9
        fromEnum :: Ind9 -> Int
fromEnum = Ind9 -> Int
indVal9

-- | Newtype wrapper for an index type that is used to represent indices with a from @0@ to @20@.
newtype Ind20 =  Ind20 {Ind20 -> Int
indVal20 :: Int}
    deriving (Eq Ind20
Eq Ind20
-> (Ind20 -> Ind20 -> Ordering)
-> (Ind20 -> Ind20 -> Bool)
-> (Ind20 -> Ind20 -> Bool)
-> (Ind20 -> Ind20 -> Bool)
-> (Ind20 -> Ind20 -> Bool)
-> (Ind20 -> Ind20 -> Ind20)
-> (Ind20 -> Ind20 -> Ind20)
-> Ord Ind20
Ind20 -> Ind20 -> Bool
Ind20 -> Ind20 -> Ordering
Ind20 -> Ind20 -> Ind20
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Ind20 -> Ind20 -> Ind20
$cmin :: Ind20 -> Ind20 -> Ind20
max :: Ind20 -> Ind20 -> Ind20
$cmax :: Ind20 -> Ind20 -> Ind20
>= :: Ind20 -> Ind20 -> Bool
$c>= :: Ind20 -> Ind20 -> Bool
> :: Ind20 -> Ind20 -> Bool
$c> :: Ind20 -> Ind20 -> Bool
<= :: Ind20 -> Ind20 -> Bool
$c<= :: Ind20 -> Ind20 -> Bool
< :: Ind20 -> Ind20 -> Bool
$c< :: Ind20 -> Ind20 -> Bool
compare :: Ind20 -> Ind20 -> Ordering
$ccompare :: Ind20 -> Ind20 -> Ordering
$cp1Ord :: Eq Ind20
Ord, Ind20 -> Ind20 -> Bool
(Ind20 -> Ind20 -> Bool) -> (Ind20 -> Ind20 -> Bool) -> Eq Ind20
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Ind20 -> Ind20 -> Bool
$c/= :: Ind20 -> Ind20 -> Bool
== :: Ind20 -> Ind20 -> Bool
$c== :: Ind20 -> Ind20 -> Bool
Eq, Int -> Ind20 -> ShowS
[Ind20] -> ShowS
Ind20 -> String
(Int -> Ind20 -> ShowS)
-> (Ind20 -> String) -> ([Ind20] -> ShowS) -> Show Ind20
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Ind20] -> ShowS
$cshowList :: [Ind20] -> ShowS
show :: Ind20 -> String
$cshow :: Ind20 -> String
showsPrec :: Int -> Ind20 -> ShowS
$cshowsPrec :: Int -> Ind20 -> ShowS
Show, ReadPrec [Ind20]
ReadPrec Ind20
Int -> ReadS Ind20
ReadS [Ind20]
(Int -> ReadS Ind20)
-> ReadS [Ind20]
-> ReadPrec Ind20
-> ReadPrec [Ind20]
-> Read Ind20
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Ind20]
$creadListPrec :: ReadPrec [Ind20]
readPrec :: ReadPrec Ind20
$creadPrec :: ReadPrec Ind20
readList :: ReadS [Ind20]
$creadList :: ReadS [Ind20]
readsPrec :: Int -> ReadS Ind20
$creadsPrec :: Int -> ReadS Ind20
Read, (forall x. Ind20 -> Rep Ind20 x)
-> (forall x. Rep Ind20 x -> Ind20) -> Generic Ind20
forall x. Rep Ind20 x -> Ind20
forall x. Ind20 -> Rep Ind20 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Ind20 x -> Ind20
$cfrom :: forall x. Ind20 -> Rep Ind20 x
Generic, Ind20 -> ()
(Ind20 -> ()) -> NFData Ind20
forall a. (a -> ()) -> NFData a
rnf :: Ind20 -> ()
$crnf :: Ind20 -> ()
NFData, Get Ind20
Putter Ind20
Putter Ind20 -> Get Ind20 -> Serialize Ind20
forall t. Putter t -> Get t -> Serialize t
get :: Get Ind20
$cget :: Get Ind20
put :: Putter Ind20
$cput :: Putter Ind20
Serialize)

instance TIndex Ind20 where

instance Enum Ind20 where
        toEnum :: Int -> Ind20
toEnum = Int -> Ind20
Ind20
        fromEnum :: Ind20 -> Int
fromEnum = Ind20 -> Int
indVal20

-- | Index tuple type for a @'Tensor'@ that provides only contravariant and covariant spacetime indices, i.e. a @'STTens'@.
type IndTupleST n1 n2 = (IndList n1 Ind3, IndList n2 Ind3)

-- | Index tuple type for a @'Tensor'@ with indices of type @'Ind20'@, @'ind9'@ and @'Ind3'@ each one appearing contravariantly and covariantly, i.e. a ‘@ATens'@.
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)

{--
Values of a given tensor should satisfy number-like properties -> more precisely should constitute an algebra (scaling, addition and multiplication).
It is important to note that only the vector space that tensors of given rank constitute closes on the type level, the product of two tensors with
given rank yields a third tensors with new rank that is hence represented by a different type.
Thus we need the values of tensors to allow for vector space operations
--}

-- Tensor Value type classes.

-- | 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.
class TAdd a where
    -- | Test whether the given element is zero, i.e. the neutral element.
    scaleZero :: a -> Bool
    -- | Addition of two elements.
    addS :: a -> a -> a
    -- | Maps an element to its additive inverse.
    negateS :: a -> a
    -- | Subtraction of two elements.
    subS :: a -> a -> a
    subS a
a a
b = a
a a -> a -> a
forall a. TAdd a => a -> a -> a
`addS` a -> a
forall a. TAdd a => a -> a
negateS a
b

-- | Newtype wrapper that is used for representing scalar values.
newtype SField a = SField a deriving (Int -> SField a -> ShowS
[SField a] -> ShowS
SField a -> String
(Int -> SField a -> ShowS)
-> (SField a -> String) -> ([SField a] -> ShowS) -> Show (SField a)
forall a. Show a => Int -> SField a -> ShowS
forall a. Show a => [SField a] -> ShowS
forall a. Show a => SField a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SField a] -> ShowS
$cshowList :: forall a. Show a => [SField a] -> ShowS
show :: SField a -> String
$cshow :: forall a. Show a => SField a -> String
showsPrec :: Int -> SField a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> SField a -> ShowS
Show, SField a -> SField a -> Bool
(SField a -> SField a -> Bool)
-> (SField a -> SField a -> Bool) -> Eq (SField a)
forall a. Eq a => SField a -> SField a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SField a -> SField a -> Bool
$c/= :: forall a. Eq a => SField a -> SField a -> Bool
== :: SField a -> SField a -> Bool
$c== :: forall a. Eq a => SField a -> SField a -> Bool
Eq, Eq (SField a)
Eq (SField a)
-> (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)
-> (SField a -> SField a -> SField a)
-> (SField a -> SField a -> SField a)
-> Ord (SField a)
SField a -> SField a -> Bool
SField a -> SField a -> Ordering
SField a -> SField a -> SField a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (SField a)
forall a. Ord a => SField a -> SField a -> Bool
forall a. Ord a => SField a -> SField a -> Ordering
forall a. Ord a => SField a -> SField a -> SField a
min :: SField a -> SField a -> SField a
$cmin :: forall a. Ord a => SField a -> SField a -> SField a
max :: SField a -> SField a -> SField a
$cmax :: forall a. Ord a => SField a -> SField a -> SField a
>= :: SField a -> SField a -> Bool
$c>= :: forall a. Ord a => SField a -> SField a -> Bool
> :: SField a -> SField a -> Bool
$c> :: forall a. Ord a => SField a -> SField a -> Bool
<= :: SField a -> SField a -> Bool
$c<= :: forall a. Ord a => SField a -> SField a -> Bool
< :: SField a -> SField a -> Bool
$c< :: forall a. Ord a => SField a -> SField a -> Bool
compare :: SField a -> SField a -> Ordering
$ccompare :: forall a. Ord a => SField a -> SField a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (SField a)
Ord, (forall x. SField a -> Rep (SField a) x)
-> (forall x. Rep (SField a) x -> SField a) -> Generic (SField a)
forall x. Rep (SField a) x -> SField a
forall x. SField a -> Rep (SField a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (SField a) x -> SField a
forall a x. SField a -> Rep (SField a) x
$cto :: forall a x. Rep (SField a) x -> SField a
$cfrom :: forall a x. SField a -> Rep (SField a) x
Generic, Get (SField a)
Putter (SField a)
Putter (SField a) -> Get (SField a) -> Serialize (SField a)
forall a. Serialize a => Get (SField a)
forall a. Serialize a => Putter (SField a)
forall t. Putter t -> Get t -> Serialize t
get :: Get (SField a)
$cget :: forall a. Serialize a => Get (SField a)
put :: Putter (SField a)
$cput :: forall a. Serialize a => Putter (SField a)
Serialize)

instance Functor SField where
    fmap :: (a -> b) -> SField a -> SField b
fmap a -> b
f (SField a
a) = b -> SField b
forall a. a -> SField a
SField (b -> SField b) -> b -> SField b
forall a b. (a -> b) -> a -> b
$ a -> b
f a
a

instance Applicative SField where
    pure :: a -> SField a
pure = a -> SField a
forall a. a -> SField a
SField
    <*> :: SField (a -> b) -> SField a -> SField b
(<*>) (SField a -> b
f) = (a -> b) -> SField a -> SField b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f

instance Num a => Num (SField a) where
    + :: SField a -> SField a -> SField a
(+) = (a -> a -> a) -> SField a -> SField a -> SField a
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Num a => a -> a -> a
(+)
    (-) = (a -> a -> a) -> SField a -> SField a -> SField a
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (-)
    * :: SField a -> SField a -> SField a
(*) = (a -> a -> a) -> SField a -> SField a -> SField a
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Num a => a -> a -> a
(*)
    negate :: SField a -> SField a
negate = (a -> a) -> SField a -> SField a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Num a => a -> a
negate
    abs :: SField a -> SField a
abs = (a -> a) -> SField a -> SField a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Num a => a -> a
abs
    signum :: SField a -> SField a
signum = (a -> a) -> SField a -> SField a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Num a => a -> a
signum
    fromInteger :: Integer -> SField a
fromInteger = a -> SField a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> SField a) -> (Integer -> a) -> Integer -> SField a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> a
forall a. Num a => Integer -> a
fromInteger

-- | Newtype wrapper for symbolic values.
--   Note that this version does not yet support simplification of symbolic values.
newtype SSymbolic = SSymbolic String deriving (Int -> SSymbolic -> ShowS
[SSymbolic] -> ShowS
SSymbolic -> String
(Int -> SSymbolic -> ShowS)
-> (SSymbolic -> String)
-> ([SSymbolic] -> ShowS)
-> Show SSymbolic
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SSymbolic] -> ShowS
$cshowList :: [SSymbolic] -> ShowS
show :: SSymbolic -> String
$cshow :: SSymbolic -> String
showsPrec :: Int -> SSymbolic -> ShowS
$cshowsPrec :: Int -> SSymbolic -> ShowS
Show, SSymbolic -> SSymbolic -> Bool
(SSymbolic -> SSymbolic -> Bool)
-> (SSymbolic -> SSymbolic -> Bool) -> Eq SSymbolic
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SSymbolic -> SSymbolic -> Bool
$c/= :: SSymbolic -> SSymbolic -> Bool
== :: SSymbolic -> SSymbolic -> Bool
$c== :: SSymbolic -> SSymbolic -> Bool
Eq, Eq SSymbolic
Eq SSymbolic
-> (SSymbolic -> SSymbolic -> Ordering)
-> (SSymbolic -> SSymbolic -> Bool)
-> (SSymbolic -> SSymbolic -> Bool)
-> (SSymbolic -> SSymbolic -> Bool)
-> (SSymbolic -> SSymbolic -> Bool)
-> (SSymbolic -> SSymbolic -> SSymbolic)
-> (SSymbolic -> SSymbolic -> SSymbolic)
-> Ord SSymbolic
SSymbolic -> SSymbolic -> Bool
SSymbolic -> SSymbolic -> Ordering
SSymbolic -> SSymbolic -> SSymbolic
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: SSymbolic -> SSymbolic -> SSymbolic
$cmin :: SSymbolic -> SSymbolic -> SSymbolic
max :: SSymbolic -> SSymbolic -> SSymbolic
$cmax :: SSymbolic -> SSymbolic -> SSymbolic
>= :: SSymbolic -> SSymbolic -> Bool
$c>= :: SSymbolic -> SSymbolic -> Bool
> :: SSymbolic -> SSymbolic -> Bool
$c> :: SSymbolic -> SSymbolic -> Bool
<= :: SSymbolic -> SSymbolic -> Bool
$c<= :: SSymbolic -> SSymbolic -> Bool
< :: SSymbolic -> SSymbolic -> Bool
$c< :: SSymbolic -> SSymbolic -> Bool
compare :: SSymbolic -> SSymbolic -> Ordering
$ccompare :: SSymbolic -> SSymbolic -> Ordering
$cp1Ord :: Eq SSymbolic
Ord, (forall x. SSymbolic -> Rep SSymbolic x)
-> (forall x. Rep SSymbolic x -> SSymbolic) -> Generic SSymbolic
forall x. Rep SSymbolic x -> SSymbolic
forall x. SSymbolic -> Rep SSymbolic x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SSymbolic x -> SSymbolic
$cfrom :: forall x. SSymbolic -> Rep SSymbolic x
Generic, Get SSymbolic
Putter SSymbolic
Putter SSymbolic -> Get SSymbolic -> Serialize SSymbolic
forall t. Putter t -> Get t -> Serialize t
get :: Get SSymbolic
$cget :: Get SSymbolic
put :: Putter SSymbolic
$cput :: Putter SSymbolic
Serialize)

instance Num SSymbolic where
    SSymbolic String
s1 + :: SSymbolic -> SSymbolic -> SSymbolic
+ SSymbolic String
s2 = String -> SSymbolic
SSymbolic (String -> SSymbolic) -> String -> SSymbolic
forall a b. (a -> b) -> a -> b
$ String
"(" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s1 String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")+(" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s2 String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
    SSymbolic String
s1 - :: SSymbolic -> SSymbolic -> SSymbolic
- SSymbolic String
s2 = String -> SSymbolic
SSymbolic (String -> SSymbolic) -> String -> SSymbolic
forall a b. (a -> b) -> a -> b
$ String
"(" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s1 String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")-(" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s2 String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
    SSymbolic String
s1 * :: SSymbolic -> SSymbolic -> SSymbolic
* SSymbolic String
s2 = String -> SSymbolic
SSymbolic (String -> SSymbolic) -> String -> SSymbolic
forall a b. (a -> b) -> a -> b
$ String
"(" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s1 String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")*(" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s2 String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
    negate :: SSymbolic -> SSymbolic
negate (SSymbolic String
s) = String -> SSymbolic
SSymbolic (String -> SSymbolic) -> String -> SSymbolic
forall a b. (a -> b) -> a -> b
$ String
"(-1)*(" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
    abs :: SSymbolic -> SSymbolic
abs (SSymbolic String
s) = String -> SSymbolic
SSymbolic (String -> SSymbolic) -> String -> SSymbolic
forall a b. (a -> b) -> a -> b
$ String
"abs(" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
    signum :: SSymbolic -> SSymbolic
signum (SSymbolic String
s) = String -> SSymbolic
SSymbolic (String -> SSymbolic) -> String -> SSymbolic
forall a b. (a -> b) -> a -> b
$ String
"signum(" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
    fromInteger :: Integer -> SSymbolic
fromInteger Integer
i = String -> SSymbolic
SSymbolic (String -> SSymbolic) -> String -> SSymbolic
forall a b. (a -> b) -> a -> b
$ String
"(" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Integer -> String
forall a. Show a => a -> String
show Integer
i String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"

-- tensor type must be instance of both.

class Epsilon a where
    nearZero :: a -> Bool

instance Epsilon Double where
    nearZero :: Double -> Bool
nearZero Double
d = Double -> Double
forall a. Num a => a -> a
abs Double
d Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
< Double
1e-12

instance Epsilon Float where
    nearZero :: Float -> Bool
nearZero Float
d = Float -> Float
forall a. Num a => a -> a
abs Float
d Float -> Float -> Bool
forall a. Ord a => a -> a -> Bool
< Float
1e-5

instance Epsilon Rational where
    nearZero :: Rational -> Bool
nearZero Rational
r = Rational
r Rational -> Rational -> Bool
forall a. Eq a => a -> a -> Bool
== Rational
0

instance Epsilon Int where
    nearZero :: Int -> Bool
nearZero Int
i = Int
i Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0

instance Epsilon Integer where
    nearZero :: Integer -> Bool
nearZero Integer
i = Integer
i Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
== Integer
0

instance (Num a, Eq a) => TAdd (SField a) where
    addS :: SField a -> SField a -> SField a
addS (SField a
a) (SField a
b) = a -> SField a
forall a. a -> SField a
SField (a -> SField a) -> a -> SField a
forall a b. (a -> b) -> a -> b
$ a
a a -> a -> a
forall a. Num a => a -> a -> a
+ a
b
    negateS :: SField a -> SField a
negateS (SField a
a) = a -> SField a
forall a. a -> SField a
SField (a -> SField a) -> a -> SField a
forall a b. (a -> b) -> a -> b
$ a -> a
forall a. Num a => a -> a
negate a
a
    scaleZero :: SField a -> Bool
scaleZero (SField a
a) = a
a a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
0

instance TAdd SSymbolic where
    addS :: SSymbolic -> SSymbolic -> SSymbolic
addS = SSymbolic -> SSymbolic -> SSymbolic
forall a. Num a => a -> a -> a
(+)
    negateS :: SSymbolic -> SSymbolic
negateS = SSymbolic -> SSymbolic
forall a. Num a => a -> a
negate
    scaleZero :: SSymbolic -> Bool
scaleZero (SSymbolic String
a) = String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
a

instance (TIndex k, TAdd v) => TAdd (Tensor n k v) where
    addS :: Tensor n k v -> Tensor n k v -> Tensor n k v
addS = Tensor n k v -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
(&+)
    negateS :: Tensor n k v -> Tensor n k v
negateS = Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v
negateTens
    scaleZero :: Tensor n k v -> Bool
scaleZero = \case
                    Tensor n k v
ZeroTensor -> Bool
True
                    Tensor n k v
_          -> Bool
False

-- | Type class for product of two (possibly different) types. The resulting type depends on the types that are given as input.
class Prod v v' where
    -- | Type level function that returns the type of the result of @'prod'@.
    type TProd v v' :: *
    -- | Product function.
    prod :: v -> v' -> TProd v v'

instance Num a => Prod (SField a) (SField a) where
    type TProd (SField a) (SField a) = SField a
    prod :: SField a -> SField a -> TProd (SField a) (SField a)
prod = SField a -> SField a -> TProd (SField a) (SField a)
forall a. Num a => a -> a -> a
(*)

instance Prod SSymbolic SSymbolic where
    type TProd SSymbolic SSymbolic = SSymbolic
    prod :: SSymbolic -> SSymbolic -> TProd SSymbolic SSymbolic
prod = SSymbolic -> SSymbolic -> TProd SSymbolic SSymbolic
forall a. Num a => a -> a -> a
(*)

instance Show a => Prod (SField a) SSymbolic where
    type TProd (SField a) SSymbolic = SSymbolic
    prod :: SField a -> SSymbolic -> TProd (SField a) SSymbolic
prod (SField a
s) = (String -> SSymbolic
SSymbolic (a -> String
forall a. Show a => a -> String
show a
s) SSymbolic -> SSymbolic -> SSymbolic
forall a. Num a => a -> a -> a
*)

instance Show a => Prod SSymbolic (SField a) where
    type TProd SSymbolic (SField a) = SSymbolic
    prod :: SSymbolic -> SField a -> TProd SSymbolic (SField a)
prod SSymbolic
a (SField a
s) = SSymbolic
a SSymbolic -> SSymbolic -> SSymbolic
forall a. Num a => a -> a -> a
* String -> SSymbolic
SSymbolic (a -> String
forall a. Show a => a -> String
show a
s)

instance (TIndex k, Prod (SField s) v) => Prod (SField s) (Tensor n k v) where
    type TProd (SField s) (Tensor n k v) = Tensor n k (TProd (SField s) v)
    prod :: SField s -> Tensor n k v -> TProd (SField s) (Tensor n k v)
prod = SField s -> Tensor n k v -> TProd (SField s) (Tensor n k v)
forall k s v (n :: Nat).
(TIndex k, Prod s v) =>
s -> Tensor n k v -> Tensor n k (TProd s v)
(&.)

instance (TIndex k, Prod (AnsVar s) v) => Prod (AnsVar s) (Tensor n k v) where
    type TProd (AnsVar s) (Tensor n k v) = Tensor n k (TProd (AnsVar s) v)
    prod :: AnsVar s -> Tensor n k v -> TProd (AnsVar s) (Tensor n k v)
prod = AnsVar s -> Tensor n k v -> TProd (AnsVar s) (Tensor n k v)
forall k s v (n :: Nat).
(TIndex k, Prod s v) =>
s -> Tensor n k v -> Tensor n k (TProd s v)
(&.)

instance (TIndex k, Prod SSymbolic v) => Prod SSymbolic (Tensor n k v) where
    type TProd SSymbolic (Tensor n k v) = Tensor n k (TProd SSymbolic v)
    prod :: SSymbolic -> Tensor n k v -> TProd SSymbolic (Tensor n k v)
prod = SSymbolic -> Tensor n k v -> TProd SSymbolic (Tensor n k v)
forall k s v (n :: Nat).
(TIndex k, Prod s v) =>
s -> Tensor n k v -> Tensor n k (TProd s v)
(&.)

instance (TIndex k, Prod v v') => Prod (Tensor n k v) (Tensor n' k v') where
    type TProd (Tensor n k v) (Tensor n' k v') = Tensor (n+n') k (TProd v v')
    prod :: Tensor n k v
-> Tensor n' k v' -> TProd (Tensor n k v) (Tensor n' k v')
prod = Tensor n k v
-> Tensor n' k v' -> TProd (Tensor n k v) (Tensor n' k v')
forall k v v' (n :: Nat) (n' :: Nat).
(TIndex k, Prod v v') =>
Tensor n k v
-> Tensor n' k v' -> TProd (Tensor n k v) (Tensor n' k v')
(&*)

-- | 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 @'AnsVar'@s.

newtype AnsVar a = AnsVar (I.IntMap a) deriving (Int -> AnsVar a -> ShowS
[AnsVar a] -> ShowS
AnsVar a -> String
(Int -> AnsVar a -> ShowS)
-> (AnsVar a -> String) -> ([AnsVar a] -> ShowS) -> Show (AnsVar a)
forall a. Show a => Int -> AnsVar a -> ShowS
forall a. Show a => [AnsVar a] -> ShowS
forall a. Show a => AnsVar a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnsVar a] -> ShowS
$cshowList :: forall a. Show a => [AnsVar a] -> ShowS
show :: AnsVar a -> String
$cshow :: forall a. Show a => AnsVar a -> String
showsPrec :: Int -> AnsVar a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> AnsVar a -> ShowS
Show, AnsVar a -> AnsVar a -> Bool
(AnsVar a -> AnsVar a -> Bool)
-> (AnsVar a -> AnsVar a -> Bool) -> Eq (AnsVar a)
forall a. Eq a => AnsVar a -> AnsVar a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnsVar a -> AnsVar a -> Bool
$c/= :: forall a. Eq a => AnsVar a -> AnsVar a -> Bool
== :: AnsVar a -> AnsVar a -> Bool
$c== :: forall a. Eq a => AnsVar a -> AnsVar a -> Bool
Eq, (forall x. AnsVar a -> Rep (AnsVar a) x)
-> (forall x. Rep (AnsVar a) x -> AnsVar a) -> Generic (AnsVar a)
forall x. Rep (AnsVar a) x -> AnsVar a
forall x. AnsVar a -> Rep (AnsVar a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (AnsVar a) x -> AnsVar a
forall a x. AnsVar a -> Rep (AnsVar a) x
$cto :: forall a x. Rep (AnsVar a) x -> AnsVar a
$cfrom :: forall a x. AnsVar a -> Rep (AnsVar a) x
Generic, Get (AnsVar a)
Putter (AnsVar a)
Putter (AnsVar a) -> Get (AnsVar a) -> Serialize (AnsVar a)
forall a. Serialize a => Get (AnsVar a)
forall a. Serialize a => Putter (AnsVar a)
forall t. Putter t -> Get t -> Serialize t
get :: Get (AnsVar a)
$cget :: forall a. Serialize a => Get (AnsVar a)
put :: Putter (AnsVar a)
$cput :: forall a. Serialize a => Putter (AnsVar a)
Serialize)

type AnsVarR = AnsVar (SField Rational)

-- | Shifts the labels of the variables that are contained in the @'AnsVar'@ type towards larger index labels by the amount specified.
shiftVarLabels :: Int -> AnsVar a -> AnsVar a
shiftVarLabels :: Int -> AnsVar a -> AnsVar a
shiftVarLabels Int
s (AnsVar IntMap a
v) = IntMap a -> AnsVar a
forall a. IntMap a -> AnsVar a
AnsVar (IntMap a -> AnsVar a) -> IntMap a -> AnsVar a
forall a b. (a -> b) -> a -> b
$ (Int -> Int) -> IntMap a -> IntMap a
forall a. (Int -> Int) -> IntMap a -> IntMap a
I.mapKeys (Int
s Int -> Int -> Int
forall a. Num a => a -> a -> a
+) IntMap a
v

-- | > shiftLabels1 s = mapTo1 (shiftVarLabels s)
shiftLabels1 :: Int -> AbsTensor1 n1 k1 (AnsVar a) -> AbsTensor1 n1 k1 (AnsVar a)
shiftLabels1 :: Int -> AbsTensor1 n1 k1 (AnsVar a) -> AbsTensor1 n1 k1 (AnsVar a)
shiftLabels1 Int
s = (AnsVar a -> AnsVar a)
-> AbsTensor1 n1 k1 (AnsVar a) -> AbsTensor1 n1 k1 (AnsVar a)
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 (Int -> AnsVar a -> AnsVar a
forall a. Int -> AnsVar a -> AnsVar a
shiftVarLabels Int
s)

-- | > shiftLabels2 s = mapTo2 (shiftVarLabels s)
shiftLabels2 :: Int -> AbsTensor2 n1 n2 k1 (AnsVar a) -> AbsTensor2 n1 n2 k1 (AnsVar a)
shiftLabels2 :: Int
-> AbsTensor2 n1 n2 k1 (AnsVar a) -> AbsTensor2 n1 n2 k1 (AnsVar a)
shiftLabels2 Int
s = (AnsVar a -> AnsVar a)
-> AbsTensor2 n1 n2 k1 (AnsVar a) -> AbsTensor2 n1 n2 k1 (AnsVar a)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 (Int -> AnsVar a -> AnsVar a
forall a. Int -> AnsVar a -> AnsVar a
shiftVarLabels Int
s)

-- | > shiftLabels3 s = mapTo3 (shiftVarLabels s)
shiftLabels3 :: Int -> AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a) -> AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a)
shiftLabels3 :: Int
-> AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a)
-> AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a)
shiftLabels3 Int
s = (AnsVar a -> AnsVar a)
-> AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a)
-> AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 (Int -> AnsVar a -> AnsVar a
forall a. Int -> AnsVar a -> AnsVar a
shiftVarLabels Int
s)

-- | > shiftLabels4 s = mapTo4 (shiftVarLabels s)
shiftLabels4 :: Int -> AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a) -> AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a)
shiftLabels4 :: Int
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a)
shiftLabels4 Int
s = (AnsVar a -> AnsVar a)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 (Int -> AnsVar a -> AnsVar a
forall a. Int -> AnsVar a -> AnsVar a
shiftVarLabels Int
s)

-- | > shiftLabels5 s = mapTo5 (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)
shiftLabels5 :: Int
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a)
shiftLabels5 Int
s = (AnsVar a -> AnsVar a)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 (Int -> AnsVar a -> AnsVar a
forall a. Int -> AnsVar a -> AnsVar a
shiftVarLabels Int
s)

-- | > shiftLabels6 s = mapTo6 (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)
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)
shiftLabels6 Int
s = (AnsVar a -> AnsVar a)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 (Int -> AnsVar a -> AnsVar a
forall a. Int -> AnsVar a -> AnsVar a
shiftVarLabels Int
s)

-- | > shiftLabels7 s = mapTo7 (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)
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)
shiftLabels7 Int
s = (AnsVar a -> AnsVar a)
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4.
(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
mapTo7 (Int -> AnsVar a -> AnsVar a
forall a. Int -> AnsVar a -> AnsVar a
shiftVarLabels Int
s)

-- | > shiftLabels8 s = mapTo8 (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)
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)
shiftLabels8 Int
s = (AnsVar a -> AnsVar a)
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) (n8 :: Nat) k1 k2 k3 k4.
(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
mapTo8 (Int -> AnsVar a -> AnsVar a
forall a. Int -> AnsVar a -> AnsVar a
shiftVarLabels Int
s)

instance TAdd a => TAdd (AnsVar a) where
    addS :: AnsVar a -> AnsVar a -> AnsVar a
addS (AnsVar IntMap a
v1) (AnsVar IntMap a
v2) = IntMap a -> AnsVar a
forall a. IntMap a -> AnsVar a
AnsVar (IntMap a -> AnsVar a) -> IntMap a -> AnsVar a
forall a b. (a -> b) -> a -> b
$ (a -> Bool) -> IntMap a -> IntMap a
forall a. (a -> Bool) -> IntMap a -> IntMap a
I.filter (Bool -> Bool
not (Bool -> Bool) -> (a -> Bool) -> a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Bool
forall a. TAdd a => a -> Bool
scaleZero) (IntMap a -> IntMap a) -> IntMap a -> IntMap a
forall a b. (a -> b) -> a -> b
$ (a -> a -> a) -> IntMap a -> IntMap a -> IntMap a
forall a. (a -> a -> a) -> IntMap a -> IntMap a -> IntMap a
I.unionWith a -> a -> a
forall a. TAdd a => a -> a -> a
addS IntMap a
v1 IntMap a
v2
    negateS :: AnsVar a -> AnsVar a
negateS (AnsVar IntMap a
v1) = IntMap a -> AnsVar a
forall a. IntMap a -> AnsVar a
AnsVar (IntMap a -> AnsVar a) -> IntMap a -> AnsVar a
forall a b. (a -> b) -> a -> b
$ (a -> a) -> IntMap a -> IntMap a
forall a b. (a -> b) -> IntMap a -> IntMap b
I.map a -> a
forall a. TAdd a => a -> a
negateS IntMap a
v1
    scaleZero :: AnsVar a -> Bool
scaleZero (AnsVar IntMap a
v) = IntMap a -> Bool
forall a. IntMap a -> Bool
I.null IntMap a
v

instance Prod (SField v) (SField v') => Prod (SField v) (AnsVar (SField v')) where
    type TProd (SField v) (AnsVar (SField v')) = AnsVar (TProd (SField v) (SField v'))
    prod :: SField v
-> AnsVar (SField v') -> TProd (SField v) (AnsVar (SField v'))
prod SField v
v (AnsVar IntMap (SField v')
v') = IntMap (TProd (SField v) (SField v'))
-> AnsVar (TProd (SField v) (SField v'))
forall a. IntMap a -> AnsVar a
AnsVar (IntMap (TProd (SField v) (SField v'))
 -> AnsVar (TProd (SField v) (SField v')))
-> IntMap (TProd (SField v) (SField v'))
-> AnsVar (TProd (SField v) (SField v'))
forall a b. (a -> b) -> a -> b
$ (SField v' -> TProd (SField v) (SField v'))
-> IntMap (SField v') -> IntMap (TProd (SField v) (SField v'))
forall a b. (a -> b) -> IntMap a -> IntMap b
I.map (SField v -> SField v' -> TProd (SField v) (SField v')
forall v v'. Prod v v' => v -> v' -> TProd v v'
prod SField v
v) IntMap (SField v')
v'

instance Prod (SField v') (SField v) => Prod (AnsVar (SField v)) (SField v') where
    type TProd (AnsVar (SField v)) (SField v') = AnsVar (TProd (SField v') (SField v))
    prod :: AnsVar (SField v)
-> SField v' -> TProd (AnsVar (SField v)) (SField v')
prod (AnsVar IntMap (SField v)
v) SField v'
v' = IntMap (TProd (SField v') (SField v))
-> AnsVar (TProd (SField v') (SField v))
forall a. IntMap a -> AnsVar a
AnsVar (IntMap (TProd (SField v') (SField v))
 -> AnsVar (TProd (SField v') (SField v)))
-> IntMap (TProd (SField v') (SField v))
-> AnsVar (TProd (SField v') (SField v))
forall a b. (a -> b) -> a -> b
$ (SField v -> TProd (SField v') (SField v))
-> IntMap (SField v) -> IntMap (TProd (SField v') (SField v))
forall a b. (a -> b) -> IntMap a -> IntMap b
I.map (SField v' -> SField v -> TProd (SField v') (SField v)
forall v v'. Prod v v' => v -> v' -> TProd v v'
prod SField v'
v') IntMap (SField v)
v

-- | Type for representation of functions as @'Tensor'@ values.
newtype CFun a b = CFun (a -> b)

instance Functor (CFun a) where
    fmap :: (a -> b) -> CFun a a -> CFun a b
fmap a -> b
f (CFun a -> a
g) = (a -> b) -> CFun a b
forall a b. (a -> b) -> CFun a b
CFun ((a -> b) -> CFun a b) -> (a -> b) -> CFun a b
forall a b. (a -> b) -> a -> b
$ a -> b
f (a -> b) -> (a -> a) -> a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a
g

instance Applicative (CFun a) where
    pure :: a -> CFun a a
pure = (a -> a) -> CFun a a
forall a b. (a -> b) -> CFun a b
CFun ((a -> a) -> CFun a a) -> (a -> a -> a) -> a -> CFun a a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a -> a
forall a b. a -> b -> a
const
    (CFun a -> a -> b
f) <*> :: CFun a (a -> b) -> CFun a a -> CFun a b
<*> (CFun a -> a
g) = (a -> b) -> CFun a b
forall a b. (a -> b) -> CFun a b
CFun ((a -> b) -> CFun a b) -> (a -> b) -> CFun a b
forall a b. (a -> b) -> a -> b
$ \a
x -> a -> a -> b
f a
x (a -> a
g a
x)

instance Num b => Num (CFun a b) where
    + :: CFun a b -> CFun a b -> CFun a b
(+) = (b -> b -> b) -> CFun a b -> CFun a b -> CFun a b
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 b -> b -> b
forall a. Num a => a -> a -> a
(+)
    * :: CFun a b -> CFun a b -> CFun a b
(*) = (b -> b -> b) -> CFun a b -> CFun a b -> CFun a b
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 b -> b -> b
forall a. Num a => a -> a -> a
(*)
    (-) = (b -> b -> b) -> CFun a b -> CFun a b -> CFun a b
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (-)
    negate :: CFun a b -> CFun a b
negate = (b -> b) -> CFun a b -> CFun a b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap b -> b
forall a. Num a => a -> a
negate
    abs :: CFun a b -> CFun a b
abs = (b -> b) -> CFun a b -> CFun a b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap b -> b
forall a. Num a => a -> a
abs
    signum :: CFun a b -> CFun a b
signum = (b -> b) -> CFun a b -> CFun a b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap b -> b
forall a. Num a => a -> a
signum
    fromInteger :: Integer -> CFun a b
fromInteger = (a -> b) -> CFun a b
forall a b. (a -> b) -> CFun a b
CFun ((a -> b) -> CFun a b)
-> (Integer -> a -> b) -> Integer -> CFun a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> a -> b
forall a b. a -> b -> a
const (b -> a -> b) -> (Integer -> b) -> Integer -> a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> b
forall a. Num a => Integer -> a
fromInteger

instance Num b => TAdd (CFun a b) where
    addS :: CFun a b -> CFun a b -> CFun a b
addS = CFun a b -> CFun a b -> CFun a b
forall a. Num a => a -> a -> a
(+)
    negateS :: CFun a b -> CFun a b
negateS = CFun a b -> CFun a b
forall a. Num a => a -> a
negate
    scaleZero :: CFun a b -> Bool
scaleZero = Bool -> CFun a b -> Bool
forall a b. a -> b -> a
const Bool
False

instance Num b => Prod (CFun a b) (CFun a b) where
    type TProd (CFun a b) (CFun a b) = CFun a b
    prod :: CFun a b -> CFun a b -> TProd (CFun a b) (CFun a b)
prod = CFun a b -> CFun a b -> TProd (CFun a b) (CFun a b)
forall a. Num a => a -> a -> a
(*)

instance Num b => Prod (SField b) (CFun a b) where
    type TProd (SField b) (CFun a b) = CFun a b
    prod :: SField b -> CFun a b -> TProd (SField b) (CFun a b)
prod (SField b
s) (CFun a -> b
f) = (a -> b) -> CFun a b
forall a b. (a -> b) -> CFun a b
CFun ((a -> b) -> CFun a b) -> (a -> b) -> CFun a b
forall a b. (a -> b) -> a -> b
$ (b -> b -> b
forall a. Num a => a -> a -> a
*b
s) (b -> b) -> (a -> b) -> a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> b
f

-- | evaluate a tensor section, i.e. a @'CFun'@-valued @'STTens'@, at given spacetime point
evalSec :: (Num b, Eq b, Epsilon b) => STTens n1 n2 (CFun a b) -> a -> STTens n1 n2 (SField b)
evalSec :: STTens n1 n2 (CFun a b) -> a -> STTens n1 n2 (SField b)
evalSec STTens n1 n2 (CFun a b)
tens a
p = STTens n1 n2 (SField b)
tens'
    where
        tList :: [(IndTuple2 n1 n2 Ind3, CFun a b)]
tList = STTens n1 n2 (CFun a b) -> [(IndTuple2 n1 n2 Ind3, CFun a b)]
forall (n1 :: Nat) (n2 :: Nat) k1 v.
AbsTensor2 n1 n2 k1 v -> [(IndTuple2 n1 n2 k1, v)]
toListT2 STTens n1 n2 (CFun a b)
tens
        tList' :: [(IndTuple2 n1 n2 Ind3, b)]
tList' = ((IndTuple2 n1 n2 Ind3, CFun a b) -> (IndTuple2 n1 n2 Ind3, b))
-> [(IndTuple2 n1 n2 Ind3, CFun a b)]
-> [(IndTuple2 n1 n2 Ind3, b)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((CFun a b -> b)
-> (IndTuple2 n1 n2 Ind3, CFun a b) -> (IndTuple2 n1 n2 Ind3, b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(CFun a -> b
f) -> a -> b
f a
p)) [(IndTuple2 n1 n2 Ind3, CFun a b)]
tList
        tList'' :: [(IndTuple2 n1 n2 Ind3, b)]
tList'' = ((IndTuple2 n1 n2 Ind3, b) -> Bool)
-> [(IndTuple2 n1 n2 Ind3, b)] -> [(IndTuple2 n1 n2 Ind3, b)]
forall a. (a -> Bool) -> [a] -> [a]
filter (\(IndTuple2 n1 n2 Ind3
_, b
v) -> Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ b -> Bool
forall a. Epsilon a => a -> Bool
nearZero b
v) [(IndTuple2 n1 n2 Ind3, b)]
tList'
        tList''' :: [(IndTuple2 n1 n2 Ind3, SField b)]
tList''' = ((IndTuple2 n1 n2 Ind3, b) -> (IndTuple2 n1 n2 Ind3, SField b))
-> [(IndTuple2 n1 n2 Ind3, b)]
-> [(IndTuple2 n1 n2 Ind3, SField b)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((b -> SField b)
-> (IndTuple2 n1 n2 Ind3, b) -> (IndTuple2 n1 n2 Ind3, SField b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap b -> SField b
forall a. a -> SField a
SField) [(IndTuple2 n1 n2 Ind3, b)]
tList''
        tens' :: STTens n1 n2 (SField b)
tens' = [(IndTuple2 n1 n2 Ind3, SField b)] -> STTens n1 n2 (SField b)
forall k1 v (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd v) =>
[(IndTuple2 n1 n2 k1, v)] -> AbsTensor2 n1 n2 k1 v
fromListT2 [(IndTuple2 n1 n2 Ind3, SField b)]
tList'''

-- compute gradient as [[a] -> a] instead of [a] -> [a]
myGrad :: Num a => [Int] -> ([AD.Forward a] -> AD.Forward a) -> [(Int, [a] -> a)]
myGrad :: [Int] -> ([Forward a] -> Forward a) -> [(Int, [a] -> a)]
myGrad [Int]
is [Forward a] -> Forward a
f = (Int -> (Int, [a] -> a)) -> [Int] -> [(Int, [a] -> a)]
forall a b. (a -> b) -> [a] -> [b]
map (\Int
i -> (Int
i, ([a] -> Int -> a
forall a. [a] -> Int -> a
!!Int
i) ([a] -> a) -> ([a] -> [a]) -> [a] -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> [a]
g)) [Int]
is
    where
        g :: [a] -> [a]
g = ([Forward a] -> Forward a) -> [a] -> [a]
forall (f :: * -> *) a.
(Traversable f, Num a) =>
(f (Forward a) -> Forward a) -> f a -> f a
AD.grad [Forward a] -> Forward a
f

-- | 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 @'TMap'@s.
type TMap k v = [(k,v)]

--insert a new key value pair in the list, if already present the function (v -> v -> v) determines the new value at the ind
insertWithTMap :: (Ord k) => (v -> v -> v) -> k -> v -> TMap k v -> TMap k v
insertWithTMap :: (v -> v -> v) -> k -> v -> TMap k v -> TMap k v
insertWithTMap v -> v -> v
_ k
key v
val [] = [(k
key,v
val)]
insertWithTMap v -> v -> v
f k
key v
val ((k
k1,v
v1):TMap k v
xs)
        | k
key k -> k -> Bool
forall a. Ord a => a -> a -> Bool
< k
k1 = (k
key,v
val) (k, v) -> TMap k v -> TMap k v
forall a. a -> [a] -> [a]
: ((k
k1,v
v1)(k, v) -> TMap k v -> TMap k v
forall a. a -> [a] -> [a]
:TMap k v
xs)
        | k
key k -> k -> Bool
forall a. Eq a => a -> a -> Bool
== k
k1 = (k
k1,v -> v -> v
f v
val v
v1) (k, v) -> TMap k v -> TMap k v
forall a. a -> [a] -> [a]
: TMap k v
xs
        | Bool
otherwise = (k
k1,v
v1) (k, v) -> TMap k v -> TMap k v
forall a. a -> [a] -> [a]
: (v -> v -> v) -> k -> v -> TMap k v -> TMap k v
forall k v.
Ord k =>
(v -> v -> v) -> k -> v -> TMap k v -> TMap k v
insertWithTMap v -> v -> v
f k
key v
val TMap k v
xs

--combine two sorted lists with combiner function
addTMaps :: (Ord k) => (v -> v -> v) -> TMap k v -> TMap k v -> TMap k v
addTMaps :: (v -> v -> v) -> TMap k v -> TMap k v -> TMap k v
addTMaps v -> v -> v
_ TMap k v
m1 [] = TMap k v
m1
addTMaps v -> v -> v
_ [] TMap k v
m2 = TMap k v
m2
addTMaps v -> v -> v
f ((k
k1,v
v1):TMap k v
xs) ((k
k2,v
v2):TMap k v
ys)
        | k
k1 k -> k -> Bool
forall a. Ord a => a -> a -> Bool
< k
k2 = (k
k1,v
v1) (k, v) -> TMap k v -> TMap k v
forall a. a -> [a] -> [a]
: (v -> v -> v) -> TMap k v -> TMap k v -> TMap k v
forall k v.
Ord k =>
(v -> v -> v) -> TMap k v -> TMap k v -> TMap k v
addTMaps v -> v -> v
f TMap k v
xs ((k
k2,v
v2)(k, v) -> TMap k v -> TMap k v
forall a. a -> [a] -> [a]
:TMap k v
ys)
        | k
k2 k -> k -> Bool
forall a. Ord a => a -> a -> Bool
< k
k1 = (k
k2,v
v2) (k, v) -> TMap k v -> TMap k v
forall a. a -> [a] -> [a]
: (v -> v -> v) -> TMap k v -> TMap k v -> TMap k v
forall k v.
Ord k =>
(v -> v -> v) -> TMap k v -> TMap k v -> TMap k v
addTMaps v -> v -> v
f ((k
k1,v
v1)(k, v) -> TMap k v -> TMap k v
forall a. a -> [a] -> [a]
:TMap k v
xs) TMap k v
ys
        | k
k1 k -> k -> Bool
forall a. Eq a => a -> a -> Bool
== k
k2 = (k
k1, v -> v -> v
f v
v1 v
v2) (k, v) -> TMap k v -> TMap k v
forall a. a -> [a] -> [a]
: (v -> v -> v) -> TMap k v -> TMap k v -> TMap k v
forall k v.
Ord k =>
(v -> v -> v) -> TMap k v -> TMap k v -> TMap k v
addTMaps v -> v -> v
f TMap k v
xs TMap k v
ys

mapTMap :: (v -> v') -> TMap k v -> TMap k v'
mapTMap :: (v -> v') -> TMap k v -> TMap k v'
mapTMap v -> v'
f = ((k, v) -> (k, v')) -> TMap k v -> TMap k v'
forall a b. (a -> b) -> [a] -> [b]
map (\(k
k,v
v) -> (k
k,v -> v'
f v
v))

filterTMap :: (v -> Bool) -> TMap k v -> TMap k v
filterTMap :: (v -> Bool) -> TMap k v -> TMap k v
filterTMap v -> Bool
f = ((k, v) -> Bool) -> TMap k v -> TMap k v
forall a. (a -> Bool) -> [a] -> [a]
filter (\(k
_,v
v) -> v -> Bool
f v
v)

-- | Basic tensor data types.
data Tensor n k v where
    -- | Constructor of leaf values.
    Scalar :: v -> Tensor 0 k v
    -- | Constructs a @'Tensor'@ from a @'TMap'@ of index sub tensor pairs.
    Tensor :: TMap k (Tensor n k v) -> Tensor (n+1) k v
    -- | Represents a @'Tensor'@ that is identical zero.
    ZeroTensor :: Tensor n k v


-- | Represents a @'Tensor'@ with attached @'Scalar'@s 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.
type Tensor2 n1 n2 k v = Tensor n1 k (Tensor n2 k v)

type AbsTensor1 n1 k1 v = Tensor n1 k1 v

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

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

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

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

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

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)

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)

-- | Type synonym for a @'Tensor'@ with contravariant and covariant spacetime indices.
type STTens n1 n2 v = AbsTensor2 n1 n2 Ind3 v

-- | 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.
type ATens n1 n2 n3 n4 n5 n6 v = AbsTensor6 n1 n2 n3 n4 n5 n6 Ind20 Ind9 Ind3 v

--for converting tensor to @'Bytestring'@s for saving and loading from file we need a non typesafe data type as intermediate type
data TensorRep k v = ScalarR v | TensorR Natural (TMap k (TensorRep k v)) | ZeroR Natural deriving (Int -> TensorRep k v -> ShowS
[TensorRep k v] -> ShowS
TensorRep k v -> String
(Int -> TensorRep k v -> ShowS)
-> (TensorRep k v -> String)
-> ([TensorRep k v] -> ShowS)
-> Show (TensorRep k v)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall k v. (Show v, Show k) => Int -> TensorRep k v -> ShowS
forall k v. (Show v, Show k) => [TensorRep k v] -> ShowS
forall k v. (Show v, Show k) => TensorRep k v -> String
showList :: [TensorRep k v] -> ShowS
$cshowList :: forall k v. (Show v, Show k) => [TensorRep k v] -> ShowS
show :: TensorRep k v -> String
$cshow :: forall k v. (Show v, Show k) => TensorRep k v -> String
showsPrec :: Int -> TensorRep k v -> ShowS
$cshowsPrec :: forall k v. (Show v, Show k) => Int -> TensorRep k v -> ShowS
Show, (forall x. TensorRep k v -> Rep (TensorRep k v) x)
-> (forall x. Rep (TensorRep k v) x -> TensorRep k v)
-> Generic (TensorRep k v)
forall x. Rep (TensorRep k v) x -> TensorRep k v
forall x. TensorRep k v -> Rep (TensorRep k v) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall k v x. Rep (TensorRep k v) x -> TensorRep k v
forall k v x. TensorRep k v -> Rep (TensorRep k v) x
$cto :: forall k v x. Rep (TensorRep k v) x -> TensorRep k v
$cfrom :: forall k v x. TensorRep k v -> Rep (TensorRep k v) x
Generic, Get (TensorRep k v)
Putter (TensorRep k v)
Putter (TensorRep k v)
-> Get (TensorRep k v) -> Serialize (TensorRep k v)
forall t. Putter t -> Get t -> Serialize t
forall k v. (Serialize v, Serialize k) => Get (TensorRep k v)
forall k v. (Serialize v, Serialize k) => Putter (TensorRep k v)
get :: Get (TensorRep k v)
$cget :: forall k v. (Serialize v, Serialize k) => Get (TensorRep k v)
put :: Putter (TensorRep k v)
$cput :: forall k v. (Serialize v, Serialize k) => Putter (TensorRep k v)
Serialize)

--convert between typesafe and non typesafe tensors

toRep :: forall n k v. KnownNat n => Tensor n k v -> TensorRep k v
toRep :: Tensor n k v -> TensorRep k v
toRep (Scalar v
v) = v -> TensorRep k v
forall k v. v -> TensorRep k v
ScalarR v
v
toRep (Tensor TMap k (Tensor n k v)
m) = case Proxy n -> IsZero n
forall (n :: Nat). KnownNat n => Proxy n -> IsZero n
isZero (Proxy n
forall k (t :: k). Proxy t
Proxy @n) of
                     IsZero n
NonZero -> let r :: Natural
r = Integer -> Natural
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Integer -> Natural) -> Integer -> Natural
forall a b. (a -> b) -> a -> b
$ Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
GHC.TypeLits.natVal (Proxy n
forall k (t :: k). Proxy t
Proxy @n)
                                in Natural -> TMap k (TensorRep k v) -> TensorRep k v
forall k v. Natural -> TMap k (TensorRep k v) -> TensorRep k v
TensorR Natural
r (TMap k (TensorRep k v) -> TensorRep k v)
-> TMap k (TensorRep k v) -> TensorRep k v
forall a b. (a -> b) -> a -> b
$ (Tensor n k v -> TensorRep k v)
-> TMap k (Tensor n k v) -> TMap k (TensorRep k v)
forall v v' k. (v -> v') -> TMap k v -> TMap k v'
mapTMap (\(t :: Tensor (n-1) k v) -> Tensor n k v -> TensorRep k v
forall (n :: Nat) k v. KnownNat n => Tensor n k v -> TensorRep k v
toRep Tensor n k v
Tensor (n - 1) k v
t) TMap k (Tensor n k v)
m
toRep Tensor n k v
ZeroTensor = let r :: Natural
r = Integer -> Natural
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Integer -> Natural) -> Integer -> Natural
forall a b. (a -> b) -> a -> b
$ Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
GHC.TypeLits.natVal (Proxy n
forall k (t :: k). Proxy t
Proxy @n)
                in Natural -> TensorRep k v
forall k v. Natural -> TensorRep k v
ZeroR Natural
r

fromRep :: forall n k v. KnownNat n => TensorRep k v -> Maybe (Tensor n k v)
fromRep :: TensorRep k v -> Maybe (Tensor n k v)
fromRep (ScalarR v
v) = case Proxy n -> IsZero n
forall (n :: Nat). KnownNat n => Proxy n -> IsZero n
isZero (Proxy n
forall k (t :: k). Proxy t
Proxy @n)
                        of IsZero n
Zero    -> Tensor 0 k v -> Maybe (Tensor 0 k v)
forall a. a -> Maybe a
Just (v -> Tensor 0 k v
forall v k. v -> Tensor 0 k v
Scalar v
v)
                           IsZero n
NonZero -> Maybe (Tensor n k v)
forall a. Maybe a
Nothing
fromRep (TensorR Natural
r TMap k (TensorRep k v)
m) = case Integer -> Maybe SomeNat
someNatVal (Natural -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
r) of
  Maybe SomeNat
Nothing -> Maybe (Tensor n k v)
forall a. Maybe a
Nothing
  Just SomeNat
l  -> case SomeNat
l of
    SomeNat (Proxy n
x' :: Proxy x) ->
     case Proxy n -> IsZero n
forall (n :: Nat). KnownNat n => Proxy n -> IsZero n
isZero Proxy n
x' of
       IsZero n
Zero    -> Maybe (Tensor n k v)
forall a. Maybe a
Nothing
       IsZero n
NonZero -> case Proxy n -> Proxy n -> Maybe (n :~: n)
forall (a :: Nat) (b :: Nat).
(KnownNat a, KnownNat b) =>
Proxy a -> Proxy b -> Maybe (a :~: b)
sameNat Proxy n
x' (Proxy n
forall k (t :: k). Proxy t
Proxy @n) of
         Maybe (n :~: n)
Nothing   -> Maybe (Tensor n k v)
forall a. Maybe a
Nothing
         Just n :~: n
Refl -> let tMap' :: TMap k (Maybe (Tensor (n - 1) k v))
tMap'   = (TensorRep k v -> Maybe (Tensor (n - 1) k v))
-> TMap k (TensorRep k v) -> TMap k (Maybe (Tensor (n - 1) k v))
forall v v' k. (v -> v') -> TMap k v -> TMap k v'
mapTMap (\TensorRep k v
t -> TensorRep k v -> Maybe (Tensor (n - 1) k v)
forall (n :: Nat) k v.
KnownNat n =>
TensorRep k v -> Maybe (Tensor n k v)
fromRep TensorRep k v
t :: Maybe (Tensor (x-1) k v)) TMap k (TensorRep k v)
m
                          tMap'' :: TMap k (Maybe (Tensor (n - 1) k v))
tMap''  = (Maybe (Tensor (n - 1) k v) -> Bool)
-> TMap k (Maybe (Tensor (n - 1) k v))
-> TMap k (Maybe (Tensor (n - 1) k v))
forall v k. (v -> Bool) -> TMap k v -> TMap k v
filterTMap (\case Maybe (Tensor (n - 1) k v)
Nothing -> Bool
False
                                                      Maybe (Tensor (n - 1) k v)
_       -> Bool
True) TMap k (Maybe (Tensor (n - 1) k v))
tMap'
                          tMap''' :: TMap k (Tensor (n - 1) k v)
tMap''' = (Maybe (Tensor (n - 1) k v) -> Tensor (n - 1) k v)
-> TMap k (Maybe (Tensor (n - 1) k v))
-> TMap k (Tensor (n - 1) k v)
forall v v' k. (v -> v') -> TMap k v -> TMap k v'
mapTMap (\(Just Tensor (n - 1) k v
t) -> Tensor (n - 1) k v
t) TMap k (Maybe (Tensor (n - 1) k v))
tMap''
                      in case TMap k (Tensor (n - 1) k v)
tMap''' of
                        [] -> Maybe (Tensor n k v)
forall a. Maybe a
Nothing
                        TMap k (Tensor (n - 1) k v)
_  -> Tensor n k v -> Maybe (Tensor n k v)
forall a. a -> Maybe a
Just (Tensor n k v -> Maybe (Tensor n k v))
-> Tensor n k v -> Maybe (Tensor n k v)
forall a b. (a -> b) -> a -> b
$ TMap k (Tensor (n - 1) k v) -> Tensor ((n - 1) + 1) k v
forall k (n :: Nat) v. TMap k (Tensor n k v) -> Tensor (n + 1) k v
Tensor TMap k (Tensor (n - 1) k v)
tMap'''
fromRep (ZeroR Natural
r) = case Integer -> Maybe SomeNat
someNatVal (Natural -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
r)
                    of Just SomeNat
_  -> Tensor n k v -> Maybe (Tensor n k v)
forall a. a -> Maybe a
Just Tensor n k v
forall (n :: Nat) k v. Tensor n k v
ZeroTensor
                       Maybe SomeNat
Nothing -> Maybe (Tensor n k v)
forall a. Maybe a
Nothing

--instances for the tensor data type

instance (NFData k, NFData v) => NFData (Tensor n k v) where
    rnf :: Tensor n k v -> ()
rnf Tensor n k v
ZeroTensor = ()
    rnf (Scalar v
v) = v
v v -> () -> ()
`seq` v -> ()
forall a. NFData a => a -> ()
rnf v
v
    rnf (Tensor TMap k (Tensor n k v)
m) = TMap k (Tensor n k v)
m TMap k (Tensor n k v) -> () -> ()
`seq` TMap k (Tensor n k v) -> ()
forall a. NFData a => a -> ()
rnf TMap k (Tensor n k v)
m

instance KnownNat n => Generic (Tensor n k v) where
    type Rep (Tensor n k v) = Rep (TensorRep k v)
    from :: Tensor n k v -> Rep (Tensor n k v) x
from = TensorRep k v
-> D1
     ('MetaData
        "TensorRep"
        "Math.Tensor"
        "sparse-tensor-0.2.1.5-3CdX3VcGAZ9BsyqgSOIuRL"
        'False)
     (C1
        ('MetaCons "ScalarR" 'PrefixI 'False)
        (S1
           ('MetaSel
              'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
           (Rec0 v))
      :+: (C1
             ('MetaCons "TensorR" 'PrefixI 'False)
             (S1
                ('MetaSel
                   'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                (Rec0 Natural)
              :*: S1
                    ('MetaSel
                       'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                    (Rec0 (TMap k (TensorRep k v))))
           :+: C1
                 ('MetaCons "ZeroR" 'PrefixI 'False)
                 (S1
                    ('MetaSel
                       'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                    (Rec0 Natural))))
     x
forall a x. Generic a => a -> Rep a x
from (TensorRep k v
 -> D1
      ('MetaData
         "TensorRep"
         "Math.Tensor"
         "sparse-tensor-0.2.1.5-3CdX3VcGAZ9BsyqgSOIuRL"
         'False)
      (C1
         ('MetaCons "ScalarR" 'PrefixI 'False)
         (S1
            ('MetaSel
               'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
            (Rec0 v))
       :+: (C1
              ('MetaCons "TensorR" 'PrefixI 'False)
              (S1
                 ('MetaSel
                    'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                 (Rec0 Natural)
               :*: S1
                     ('MetaSel
                        'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                     (Rec0 (TMap k (TensorRep k v))))
            :+: C1
                  ('MetaCons "ZeroR" 'PrefixI 'False)
                  (S1
                     ('MetaSel
                        'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                     (Rec0 Natural))))
      x)
-> (Tensor n k v -> TensorRep k v)
-> Tensor n k v
-> D1
     ('MetaData
        "TensorRep"
        "Math.Tensor"
        "sparse-tensor-0.2.1.5-3CdX3VcGAZ9BsyqgSOIuRL"
        'False)
     (C1
        ('MetaCons "ScalarR" 'PrefixI 'False)
        (S1
           ('MetaSel
              'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
           (Rec0 v))
      :+: (C1
             ('MetaCons "TensorR" 'PrefixI 'False)
             (S1
                ('MetaSel
                   'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                (Rec0 Natural)
              :*: S1
                    ('MetaSel
                       'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                    (Rec0 (TMap k (TensorRep k v))))
           :+: C1
                 ('MetaCons "ZeroR" 'PrefixI 'False)
                 (S1
                    ('MetaSel
                       'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                    (Rec0 Natural))))
     x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tensor n k v -> TensorRep k v
forall (n :: Nat) k v. KnownNat n => Tensor n k v -> TensorRep k v
toRep
    to :: Rep (Tensor n k v) x -> Tensor n k v
to   = \case
              Maybe (Tensor n k v)
Nothing -> String -> Tensor n k v
forall a. HasCallStack => String -> a
error String
"Could not reconstruct tensor from representation."
              Just Tensor n k v
t  -> Tensor n k v
t
           (Maybe (Tensor n k v) -> Tensor n k v)
-> (M1
      D
      ('MetaData
         "TensorRep"
         "Math.Tensor"
         "sparse-tensor-0.2.1.5-3CdX3VcGAZ9BsyqgSOIuRL"
         'False)
      (C1
         ('MetaCons "ScalarR" 'PrefixI 'False)
         (S1
            ('MetaSel
               'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
            (Rec0 v))
       :+: (C1
              ('MetaCons "TensorR" 'PrefixI 'False)
              (S1
                 ('MetaSel
                    'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                 (Rec0 Natural)
               :*: S1
                     ('MetaSel
                        'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                     (Rec0 (TMap k (TensorRep k v))))
            :+: C1
                  ('MetaCons "ZeroR" 'PrefixI 'False)
                  (S1
                     ('MetaSel
                        'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                     (Rec0 Natural))))
      x
    -> Maybe (Tensor n k v))
-> M1
     D
     ('MetaData
        "TensorRep"
        "Math.Tensor"
        "sparse-tensor-0.2.1.5-3CdX3VcGAZ9BsyqgSOIuRL"
        'False)
     (C1
        ('MetaCons "ScalarR" 'PrefixI 'False)
        (S1
           ('MetaSel
              'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
           (Rec0 v))
      :+: (C1
             ('MetaCons "TensorR" 'PrefixI 'False)
             (S1
                ('MetaSel
                   'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                (Rec0 Natural)
              :*: S1
                    ('MetaSel
                       'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                    (Rec0 (TMap k (TensorRep k v))))
           :+: C1
                 ('MetaCons "ZeroR" 'PrefixI 'False)
                 (S1
                    ('MetaSel
                       'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                    (Rec0 Natural))))
     x
-> Tensor n k v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TensorRep k v -> Maybe (Tensor n k v)
forall (n :: Nat) k v.
KnownNat n =>
TensorRep k v -> Maybe (Tensor n k v)
fromRep (TensorRep k v -> Maybe (Tensor n k v))
-> (M1
      D
      ('MetaData
         "TensorRep"
         "Math.Tensor"
         "sparse-tensor-0.2.1.5-3CdX3VcGAZ9BsyqgSOIuRL"
         'False)
      (C1
         ('MetaCons "ScalarR" 'PrefixI 'False)
         (S1
            ('MetaSel
               'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
            (Rec0 v))
       :+: (C1
              ('MetaCons "TensorR" 'PrefixI 'False)
              (S1
                 ('MetaSel
                    'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                 (Rec0 Natural)
               :*: S1
                     ('MetaSel
                        'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                     (Rec0 (TMap k (TensorRep k v))))
            :+: C1
                  ('MetaCons "ZeroR" 'PrefixI 'False)
                  (S1
                     ('MetaSel
                        'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                     (Rec0 Natural))))
      x
    -> TensorRep k v)
-> M1
     D
     ('MetaData
        "TensorRep"
        "Math.Tensor"
        "sparse-tensor-0.2.1.5-3CdX3VcGAZ9BsyqgSOIuRL"
        'False)
     (C1
        ('MetaCons "ScalarR" 'PrefixI 'False)
        (S1
           ('MetaSel
              'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
           (Rec0 v))
      :+: (C1
             ('MetaCons "TensorR" 'PrefixI 'False)
             (S1
                ('MetaSel
                   'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                (Rec0 Natural)
              :*: S1
                    ('MetaSel
                       'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                    (Rec0 (TMap k (TensorRep k v))))
           :+: C1
                 ('MetaCons "ZeroR" 'PrefixI 'False)
                 (S1
                    ('MetaSel
                       'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                    (Rec0 Natural))))
     x
-> Maybe (Tensor n k v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. M1
  D
  ('MetaData
     "TensorRep"
     "Math.Tensor"
     "sparse-tensor-0.2.1.5-3CdX3VcGAZ9BsyqgSOIuRL"
     'False)
  (C1
     ('MetaCons "ScalarR" 'PrefixI 'False)
     (S1
        ('MetaSel
           'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
        (Rec0 v))
   :+: (C1
          ('MetaCons "TensorR" 'PrefixI 'False)
          (S1
             ('MetaSel
                'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
             (Rec0 Natural)
           :*: S1
                 ('MetaSel
                    'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                 (Rec0 (TMap k (TensorRep k v))))
        :+: C1
              ('MetaCons "ZeroR" 'PrefixI 'False)
              (S1
                 ('MetaSel
                    'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
                 (Rec0 Natural))))
  x
-> TensorRep k v
forall a x. Generic a => Rep a x -> a
to

deriving instance (KnownNat n, Ord k, Serialize k, Serialize v) => Serialize (Tensor n k v)

instance Functor (Tensor n k) where
    fmap :: (a -> b) -> Tensor n k a -> Tensor n k b
fmap a -> b
f (Scalar a
x) = b -> Tensor 0 k b
forall v k. v -> Tensor 0 k v
Scalar (a -> b
f a
x)
    fmap a -> b
f (Tensor TMap k (Tensor n k a)
m) = TMap k (Tensor n k b) -> Tensor (n + 1) k b
forall k (n :: Nat) v. TMap k (Tensor n k v) -> Tensor (n + 1) k v
Tensor ((Tensor n k a -> Tensor n k b)
-> TMap k (Tensor n k a) -> TMap k (Tensor n k b)
forall v v' k. (v -> v') -> TMap k v -> TMap k v'
mapTMap ((a -> b) -> Tensor n k a -> Tensor n k b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) TMap k (Tensor n k a)
m)
    fmap a -> b
_ Tensor n k a
ZeroTensor = Tensor n k b
forall (n :: Nat) k v. Tensor n k v
ZeroTensor

deriving instance (Show a, Show k) => Show (Tensor n k a)

deriving instance (Eq a, Eq k) => Eq (Tensor n k a)

getTensorMap :: forall n k v.(1 <= n) => Tensor n k v -> TMap k (Tensor (n-1) k v)
getTensorMap :: Tensor n k v -> TMap k (Tensor (n - 1) k v)
getTensorMap (Tensor TMap k (Tensor n k v)
m) = TMap k (Tensor n k v)
TMap k (Tensor (n - 1) k v)
m
getTensorMap Tensor n k v
ZeroTensor = []

toMatListT1' :: (TIndex k1, TAdd a) => AbsTensor1 n1 k1 (AnsVar a) -> [((Int,Int),a)]
toMatListT1' :: AbsTensor1 n1 k1 (AnsVar a) -> [((Int, Int), a)]
toMatListT1' = [[(Int, a)]] -> [((Int, Int), a)]
forall a. [[(Int, a)]] -> [((Int, Int), a)]
collectMatList ([[(Int, a)]] -> [((Int, Int), a)])
-> (AbsTensor1 n1 k1 (AnsVar a) -> [[(Int, a)]])
-> AbsTensor1 n1 k1 (AnsVar a)
-> [((Int, Int), a)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbsTensor1 n1 k1 (AnsVar a) -> [[(Int, a)]]
forall k1 a (n1 :: Nat).
(TIndex k1, TAdd a) =>
AbsTensor1 n1 k1 (AnsVar a) -> [[(Int, a)]]
toMatList1'

toMatListT2' :: (TIndex k1, TAdd a) => AbsTensor2 n1 n2 k1 (AnsVar a) -> [((Int,Int),a)]
toMatListT2' :: AbsTensor2 n1 n2 k1 (AnsVar a) -> [((Int, Int), a)]
toMatListT2' = [[(Int, a)]] -> [((Int, Int), a)]
forall a. [[(Int, a)]] -> [((Int, Int), a)]
collectMatList ([[(Int, a)]] -> [((Int, Int), a)])
-> (AbsTensor2 n1 n2 k1 (AnsVar a) -> [[(Int, a)]])
-> AbsTensor2 n1 n2 k1 (AnsVar a)
-> [((Int, Int), a)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbsTensor2 n1 n2 k1 (AnsVar a) -> [[(Int, a)]]
forall k1 a (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd a) =>
AbsTensor2 n1 n2 k1 (AnsVar a) -> [[(Int, a)]]
toMatList2'

toMatListT3' :: (TIndex k1, TIndex k2, TAdd a) => AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a) -> [((Int,Int),a)]
toMatListT3' :: AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a) -> [((Int, Int), a)]
toMatListT3' = [[(Int, a)]] -> [((Int, Int), a)]
forall a. [[(Int, a)]] -> [((Int, Int), a)]
collectMatList ([[(Int, a)]] -> [((Int, Int), a)])
-> (AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a) -> [[(Int, a)]])
-> AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a)
-> [((Int, Int), a)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a) -> [[(Int, a)]]
forall k1 k2 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat).
(TIndex k1, TIndex k2, TAdd a) =>
AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a) -> [[(Int, a)]]
toMatList3'

toMatListT4' :: (TIndex k1, TIndex k2, TAdd a) => AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a) -> [((Int,Int),a)]
toMatListT4' :: AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a) -> [((Int, Int), a)]
toMatListT4' = [[(Int, a)]] -> [((Int, Int), a)]
forall a. [[(Int, a)]] -> [((Int, Int), a)]
collectMatList ([[(Int, a)]] -> [((Int, Int), a)])
-> (AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a) -> [[(Int, a)]])
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a)
-> [((Int, Int), a)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a) -> [[(Int, a)]]
forall k1 k2 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat).
(TIndex k1, TIndex k2, TAdd a) =>
AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a) -> [[(Int, a)]]
toMatList4'

toMatListT5' :: (TIndex k1, TIndex k2, TIndex k3, TAdd a) => AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a) -> [((Int,Int),a)]
toMatListT5' :: AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a) -> [((Int, Int), a)]
toMatListT5' = [[(Int, a)]] -> [((Int, Int), a)]
forall a. [[(Int, a)]] -> [((Int, Int), a)]
collectMatList ([[(Int, a)]] -> [((Int, Int), a)])
-> (AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a) -> [[(Int, a)]])
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a)
-> [((Int, Int), a)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a) -> [[(Int, a)]]
forall k1 k2 k3 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat).
(TIndex k1, TIndex k2, TIndex k3, TAdd a) =>
AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a) -> [[(Int, a)]]
toMatList5'

toMatListT6' :: (TIndex k1, TIndex k2, TIndex k3, TAdd a) => AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a) -> [((Int,Int),a)]
toMatListT6' :: AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a)
-> [((Int, Int), a)]
toMatListT6' = [[(Int, a)]] -> [((Int, Int), a)]
forall a. [[(Int, a)]] -> [((Int, Int), a)]
collectMatList ([[(Int, a)]] -> [((Int, Int), a)])
-> (AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a)
    -> [[(Int, a)]])
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a)
-> [((Int, Int), a)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a) -> [[(Int, a)]]
forall k1 k2 k3 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat).
(TIndex k1, TIndex k2, TIndex k3, TAdd a) =>
AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a) -> [[(Int, a)]]
toMatList6'

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)]
toMatListT7' :: AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar a)
-> [((Int, Int), a)]
toMatListT7' = [[(Int, a)]] -> [((Int, Int), a)]
forall a. [[(Int, a)]] -> [((Int, Int), a)]
collectMatList ([[(Int, a)]] -> [((Int, Int), a)])
-> (AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar a)
    -> [[(Int, a)]])
-> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar a)
-> [((Int, Int), a)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar a)
-> [[(Int, a)]]
forall k1 k2 k3 k4 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat)
       (n4 :: Nat) (n5 :: Nat) (n6 :: Nat) (n7 :: Nat).
(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, a)]]
toMatList7'

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)]
toMatListT8' :: AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar a)
-> [((Int, Int), a)]
toMatListT8' = [[(Int, a)]] -> [((Int, Int), a)]
forall a. [[(Int, a)]] -> [((Int, Int), a)]
collectMatList ([[(Int, a)]] -> [((Int, Int), a)])
-> (AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar a)
    -> [[(Int, a)]])
-> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar a)
-> [((Int, Int), a)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar a)
-> [[(Int, a)]]
forall k1 k2 k3 k4 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat)
       (n4 :: Nat) (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) (n8 :: Nat).
(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, a)]]
toMatList8'

toMatrixT1' :: (TIndex k1, Real a) => AbsTensor1 n1 k1 (AnsVar (SField a)) -> HM.Matrix Double
toMatrixT1' :: AbsTensor1 n1 k1 (AnsVar (SField a)) -> Matrix Double
toMatrixT1' = [((Int, Int), SField a)] -> Matrix Double
forall a. Real a => [((Int, Int), SField a)] -> Matrix Double
assocsToMatrix ([((Int, Int), SField a)] -> Matrix Double)
-> (AbsTensor1 n1 k1 (AnsVar (SField a))
    -> [((Int, Int), SField a)])
-> AbsTensor1 n1 k1 (AnsVar (SField a))
-> Matrix Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbsTensor1 n1 k1 (AnsVar (SField a)) -> [((Int, Int), SField a)]
forall k1 a (n1 :: Nat).
(TIndex k1, TAdd a) =>
AbsTensor1 n1 k1 (AnsVar a) -> [((Int, Int), a)]
toMatListT1'

toMatrixT2' :: (TIndex k1, Real a) => AbsTensor2 n1 n2 k1 (AnsVar (SField a)) -> HM.Matrix Double
toMatrixT2' :: AbsTensor2 n1 n2 k1 (AnsVar (SField a)) -> Matrix Double
toMatrixT2' = [((Int, Int), SField a)] -> Matrix Double
forall a. Real a => [((Int, Int), SField a)] -> Matrix Double
assocsToMatrix ([((Int, Int), SField a)] -> Matrix Double)
-> (AbsTensor2 n1 n2 k1 (AnsVar (SField a))
    -> [((Int, Int), SField a)])
-> AbsTensor2 n1 n2 k1 (AnsVar (SField a))
-> Matrix Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbsTensor2 n1 n2 k1 (AnsVar (SField a)) -> [((Int, Int), SField a)]
forall k1 a (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd a) =>
AbsTensor2 n1 n2 k1 (AnsVar a) -> [((Int, Int), a)]
toMatListT2'

toMatrixT3' :: (TIndex k1, TIndex k2, Real a) => AbsTensor3 n1 n2 n3 k1 k2 (AnsVar (SField a)) -> HM.Matrix Double
toMatrixT3' :: AbsTensor3 n1 n2 n3 k1 k2 (AnsVar (SField a)) -> Matrix Double
toMatrixT3' = [((Int, Int), SField a)] -> Matrix Double
forall a. Real a => [((Int, Int), SField a)] -> Matrix Double
assocsToMatrix ([((Int, Int), SField a)] -> Matrix Double)
-> (AbsTensor3 n1 n2 n3 k1 k2 (AnsVar (SField a))
    -> [((Int, Int), SField a)])
-> AbsTensor3 n1 n2 n3 k1 k2 (AnsVar (SField a))
-> Matrix Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbsTensor3 n1 n2 n3 k1 k2 (AnsVar (SField a))
-> [((Int, Int), SField a)]
forall k1 k2 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat).
(TIndex k1, TIndex k2, TAdd a) =>
AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a) -> [((Int, Int), a)]
toMatListT3'

toMatrixT4' :: (TIndex k1, TIndex k2, Real a) => AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar (SField a)) -> HM.Matrix Double
toMatrixT4' :: AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar (SField a)) -> Matrix Double
toMatrixT4' = [((Int, Int), SField a)] -> Matrix Double
forall a. Real a => [((Int, Int), SField a)] -> Matrix Double
assocsToMatrix ([((Int, Int), SField a)] -> Matrix Double)
-> (AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar (SField a))
    -> [((Int, Int), SField a)])
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar (SField a))
-> Matrix Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar (SField a))
-> [((Int, Int), SField a)]
forall k1 k2 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat).
(TIndex k1, TIndex k2, TAdd a) =>
AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a) -> [((Int, Int), a)]
toMatListT4'

toMatrixT5' :: (TIndex k1, TIndex k2, TIndex k3, Real a) => AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar (SField a)) -> HM.Matrix Double
toMatrixT5' :: AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar (SField a))
-> Matrix Double
toMatrixT5' = [((Int, Int), SField a)] -> Matrix Double
forall a. Real a => [((Int, Int), SField a)] -> Matrix Double
assocsToMatrix ([((Int, Int), SField a)] -> Matrix Double)
-> (AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar (SField a))
    -> [((Int, Int), SField a)])
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar (SField a))
-> Matrix Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar (SField a))
-> [((Int, Int), SField a)]
forall k1 k2 k3 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat).
(TIndex k1, TIndex k2, TIndex k3, TAdd a) =>
AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a) -> [((Int, Int), a)]
toMatListT5'

toMatrixT6' :: (TIndex k1, TIndex k2, TIndex k3, Real a) => AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar (SField a)) -> HM.Matrix Double
toMatrixT6' :: AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar (SField a))
-> Matrix Double
toMatrixT6' = [((Int, Int), SField a)] -> Matrix Double
forall a. Real a => [((Int, Int), SField a)] -> Matrix Double
assocsToMatrix ([((Int, Int), SField a)] -> Matrix Double)
-> (AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar (SField a))
    -> [((Int, Int), SField a)])
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar (SField a))
-> Matrix Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar (SField a))
-> [((Int, Int), SField a)]
forall k1 k2 k3 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat).
(TIndex k1, TIndex k2, TIndex k3, TAdd a) =>
AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a)
-> [((Int, Int), a)]
toMatListT6'

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)) -> HM.Matrix Double
toMatrixT7' :: AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar (SField a))
-> Matrix Double
toMatrixT7' = [((Int, Int), SField a)] -> Matrix Double
forall a. Real a => [((Int, Int), SField a)] -> Matrix Double
assocsToMatrix ([((Int, Int), SField a)] -> Matrix Double)
-> (AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar (SField a))
    -> [((Int, Int), SField a)])
-> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar (SField a))
-> Matrix Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar (SField a))
-> [((Int, Int), SField a)]
forall k1 k2 k3 k4 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat)
       (n4 :: Nat) (n5 :: Nat) (n6 :: Nat) (n7 :: Nat).
(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)]
toMatListT7'

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)) -> HM.Matrix Double
toMatrixT8' :: AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar (SField a))
-> Matrix Double
toMatrixT8' = [((Int, Int), SField a)] -> Matrix Double
forall a. Real a => [((Int, Int), SField a)] -> Matrix Double
assocsToMatrix ([((Int, Int), SField a)] -> Matrix Double)
-> (AbsTensor8
      n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar (SField a))
    -> [((Int, Int), SField a)])
-> AbsTensor8
     n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar (SField a))
-> Matrix Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar (SField a))
-> [((Int, Int), SField a)]
forall k1 k2 k3 k4 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat)
       (n4 :: Nat) (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) (n8 :: Nat).
(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)]
toMatListT8'



--construct from typed list

mkTens :: (IndList n k, v) -> Tensor n k v
mkTens :: (IndList n k, v) -> Tensor n k v
mkTens (IndList n k
Empty, v
a) = v -> Tensor 0 k v
forall v k. v -> Tensor 0 k v
Scalar v
a
mkTens (Append k
x IndList (n - 1) k
xs, v
a) = TMap k (Tensor (n - 1) k v) -> Tensor ((n - 1) + 1) k v
forall k (n :: Nat) v. TMap k (Tensor n k v) -> Tensor (n + 1) k v
Tensor  [(k
x, (IndList (n - 1) k, v) -> Tensor (n - 1) k v
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList (n - 1) k
xs, v
a))]

-- | This functions construction @'Tensor'@s 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.
fromListT :: (TIndex k, TAdd v) => [(IndList n k, v)] -> Tensor n k v
fromListT :: [(IndList n k, v)] -> Tensor n k v
fromListT [(IndList n k, v)
x] = (IndList n k, v) -> Tensor n k v
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n k, v)
x
fromListT ((IndList n k, v)
x:[(IndList n k, v)]
xs) = ((IndList n k, v) -> Tensor n k v -> Tensor n k v)
-> Tensor n k v -> [(IndList n k, v)] -> Tensor n k v
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (IndList n k, v) -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(IndList n k, v) -> Tensor n k v -> Tensor n k v
insertOrAdd ((IndList n k, v) -> Tensor n k v
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n k, v)
x) [(IndList n k, v)]
xs
fromListT [] = Tensor n k v
forall (n :: Nat) k v. Tensor n k v
ZeroTensor

-- | 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'@.
fromListT' :: forall n k v. (TIndex k, TAdd v, KnownNat n) => [([k],v)] -> Tensor n k v
fromListT' :: [([k], v)] -> Tensor n k v
fromListT' [([k], v)]
l = [(IndList n k, v)] -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[(IndList n k, v)] -> Tensor n k v
fromListT [(IndList n k, v)]
indList
        where
            indList :: [(IndList n k, v)]
indList = (([k], v) -> (IndList n k, v)) -> [([k], v)] -> [(IndList n k, v)]
forall a b. (a -> b) -> [a] -> [b]
map (\([k]
x,v
y) -> ([k] -> IndList n k
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k]
x, v
y)) [([k], v)]
l

fromListT1 :: (TIndex k1, TAdd v) => [(IndTuple1 n1 k1, v)] -> AbsTensor1 n1 k1 v
fromListT1 :: [(IndTuple1 n1 k1, v)] -> AbsTensor1 n1 k1 v
fromListT1 = [(IndTuple1 n1 k1, v)] -> AbsTensor1 n1 k1 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[(IndList n k, v)] -> Tensor n k v
fromListT

fromListT1' :: forall n1 k1 v. (KnownNat n1, TIndex k1, TAdd v) => [([k1],v)] -> AbsTensor1 n1 k1 v
fromListT1' :: [([k1], v)] -> AbsTensor1 n1 k1 v
fromListT1' = [([k1], v)] -> AbsTensor1 n1 k1 v
forall (n :: Nat) k v.
(TIndex k, TAdd v, KnownNat n) =>
[([k], v)] -> Tensor n k v
fromListT'

fromListT2 :: (TIndex k1, TAdd v) => [(IndTuple2 n1 n2 k1, v)] -> AbsTensor2 n1 n2 k1 v
fromListT2 :: [(IndTuple2 n1 n2 k1, v)] -> AbsTensor2 n1 n2 k1 v
fromListT2 [(IndTuple2 n1 n2 k1, v)]
l = (AbsTensor2 n1 n2 k1 v
 -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v)
-> AbsTensor2 n1 n2 k1 v
-> [AbsTensor2 n1 n2 k1 v]
-> AbsTensor2 n1 n2 k1 v
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
(&+) AbsTensor2 n1 n2 k1 v
forall (n :: Nat) k v. Tensor n k v
ZeroTensor [AbsTensor2 n1 n2 k1 v]
tensList
    where
        tensList :: [AbsTensor2 n1 n2 k1 v]
tensList = ((IndTuple2 n1 n2 k1, v) -> AbsTensor2 n1 n2 k1 v)
-> [(IndTuple2 n1 n2 k1, v)] -> [AbsTensor2 n1 n2 k1 v]
forall a b. (a -> b) -> [a] -> [b]
map (IndTuple2 n1 n2 k1, v) -> AbsTensor2 n1 n2 k1 v
forall (n1 :: Nat) (n2 :: Nat) k1 v.
(IndTuple2 n1 n2 k1, v) -> AbsTensor2 n1 n2 k1 v
mkTens2 [(IndTuple2 n1 n2 k1, v)]
l

fromListT2' :: forall n1 n2 k1 v. (KnownNat n1, KnownNat n2, TIndex k1, TAdd v) => [(([k1],[k1]),v)] -> AbsTensor2 n1 n2 k1 v
fromListT2' :: [(([k1], [k1]), v)] -> AbsTensor2 n1 n2 k1 v
fromListT2' [(([k1], [k1]), v)]
l = [(IndTuple2 n1 n2 k1, v)] -> AbsTensor2 n1 n2 k1 v
forall k1 v (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd v) =>
[(IndTuple2 n1 n2 k1, v)] -> AbsTensor2 n1 n2 k1 v
fromListT2 [(IndTuple2 n1 n2 k1, v)]
indList
        where
            indList :: [(IndTuple2 n1 n2 k1, v)]
indList = ((([k1], [k1]), v) -> (IndTuple2 n1 n2 k1, v))
-> [(([k1], [k1]), v)] -> [(IndTuple2 n1 n2 k1, v)]
forall a b. (a -> b) -> [a] -> [b]
map (\(([k1]
x1,[k1]
x2),v
y) -> (([k1] -> IndList n1 k1
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k1]
x1, [k1] -> IndList n2 k1
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k1]
x2),v
y)) [(([k1], [k1]), v)]
l

fromListT3 :: (TIndex k1, TIndex k2, TAdd v) => [(IndTuple3 n1 n2 n3 k1 k2, v)] -> AbsTensor3 n1 n2 n3 k1 k2 v
fromListT3 :: [(IndTuple3 n1 n2 n3 k1 k2, v)] -> AbsTensor3 n1 n2 n3 k1 k2 v
fromListT3 [(IndTuple3 n1 n2 n3 k1 k2, v)]
l = (AbsTensor3 n1 n2 n3 k1 k2 v
 -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v)
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> [AbsTensor3 n1 n2 n3 k1 k2 v]
-> AbsTensor3 n1 n2 n3 k1 k2 v
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
(&+) AbsTensor3 n1 n2 n3 k1 k2 v
forall (n :: Nat) k v. Tensor n k v
ZeroTensor [AbsTensor3 n1 n2 n3 k1 k2 v]
tensList
    where
        tensList :: [AbsTensor3 n1 n2 n3 k1 k2 v]
tensList = ((IndTuple3 n1 n2 n3 k1 k2, v) -> AbsTensor3 n1 n2 n3 k1 k2 v)
-> [(IndTuple3 n1 n2 n3 k1 k2, v)] -> [AbsTensor3 n1 n2 n3 k1 k2 v]
forall a b. (a -> b) -> [a] -> [b]
map (IndTuple3 n1 n2 n3 k1 k2, v) -> AbsTensor3 n1 n2 n3 k1 k2 v
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2 v.
(IndTuple3 n1 n2 n3 k1 k2, v) -> AbsTensor3 n1 n2 n3 k1 k2 v
mkTens3 [(IndTuple3 n1 n2 n3 k1 k2, v)]
l

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
fromListT3' :: [(([k1], [k1], [k2]), v)] -> AbsTensor3 n1 n2 n3 k1 k2 v
fromListT3' [(([k1], [k1], [k2]), v)]
l = [(IndTuple3 n1 n2 n3 k1 k2, v)] -> AbsTensor3 n1 n2 n3 k1 k2 v
forall k1 k2 v (n1 :: Nat) (n2 :: Nat) (n3 :: Nat).
(TIndex k1, TIndex k2, TAdd v) =>
[(IndTuple3 n1 n2 n3 k1 k2, v)] -> AbsTensor3 n1 n2 n3 k1 k2 v
fromListT3 [(IndTuple3 n1 n2 n3 k1 k2, v)]
indList
        where
            indList :: [(IndTuple3 n1 n2 n3 k1 k2, v)]
indList = ((([k1], [k1], [k2]), v) -> (IndTuple3 n1 n2 n3 k1 k2, v))
-> [(([k1], [k1], [k2]), v)] -> [(IndTuple3 n1 n2 n3 k1 k2, v)]
forall a b. (a -> b) -> [a] -> [b]
map (\(([k1]
x1,[k1]
x2,[k2]
x3),v
y) -> (([k1] -> IndList n1 k1
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k1]
x1, [k1] -> IndList n2 k1
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k1]
x2, [k2] -> IndList n3 k2
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k2]
x3),v
y)) [(([k1], [k1], [k2]), v)]
l

fromListT4 :: (TIndex k1, TIndex k2, TAdd v) => [(IndTuple4 n1 n2 n3 n4 k1 k2, v)] -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
fromListT4 :: [(IndTuple4 n1 n2 n3 n4 k1 k2, v)]
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
fromListT4 [(IndTuple4 n1 n2 n3 n4 k1 k2, v)]
l = (AbsTensor4 n1 n2 n3 n4 k1 k2 v
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> [AbsTensor4 n1 n2 n3 n4 k1 k2 v]
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
(&+) AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall (n :: Nat) k v. Tensor n k v
ZeroTensor [AbsTensor4 n1 n2 n3 n4 k1 k2 v]
tensList
    where
        tensList :: [AbsTensor4 n1 n2 n3 n4 k1 k2 v]
tensList = ((IndTuple4 n1 n2 n3 n4 k1 k2, v)
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v)
-> [(IndTuple4 n1 n2 n3 n4 k1 k2, v)]
-> [AbsTensor4 n1 n2 n3 n4 k1 k2 v]
forall a b. (a -> b) -> [a] -> [b]
map (IndTuple4 n1 n2 n3 n4 k1 k2, v) -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2 v.
(IndTuple4 n1 n2 n3 n4 k1 k2, v) -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
mkTens4 [(IndTuple4 n1 n2 n3 n4 k1 k2, v)]
l

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
fromListT4' :: [(([k1], [k1], [k2], [k2]), v)] -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
fromListT4' [(([k1], [k1], [k2], [k2]), v)]
l = [(IndTuple4 n1 n2 n3 n4 k1 k2, v)]
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall k1 k2 v (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat).
(TIndex k1, TIndex k2, TAdd v) =>
[(IndTuple4 n1 n2 n3 n4 k1 k2, v)]
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
fromListT4 [(IndTuple4 n1 n2 n3 n4 k1 k2, v)]
indList
        where
            indList :: [(IndTuple4 n1 n2 n3 n4 k1 k2, v)]
indList = ((([k1], [k1], [k2], [k2]), v) -> (IndTuple4 n1 n2 n3 n4 k1 k2, v))
-> [(([k1], [k1], [k2], [k2]), v)]
-> [(IndTuple4 n1 n2 n3 n4 k1 k2, v)]
forall a b. (a -> b) -> [a] -> [b]
map (\(([k1]
x1,[k1]
x2,[k2]
x3,[k2]
x4),v
y) -> (([k1] -> IndList n1 k1
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k1]
x1, [k1] -> IndList n2 k1
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k1]
x2, [k2] -> IndList n3 k2
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k2]
x3, [k2] -> IndList n4 k2
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k2]
x4),v
y)) [(([k1], [k1], [k2], [k2]), v)]
l

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
fromListT5 :: [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)]
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
fromListT5 [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)]
l = (AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> [AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v]
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
(&+) AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall (n :: Nat) k v. Tensor n k v
ZeroTensor [AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v]
tensList
    where
        tensList :: [AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v]
tensList = ((IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v)
-> [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)]
-> [AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v]
forall a b. (a -> b) -> [a] -> [b]
map (IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       k1 k2 k3 v.
(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
mkTens5 [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)]
l

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
fromListT5' :: [(([k1], [k1], [k2], [k2], [k3]), v)]
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
fromListT5' [(([k1], [k1], [k2], [k2], [k3]), v)]
l = [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)]
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall k1 k2 k3 v (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat).
(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
fromListT5 [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)]
indList
        where
            indList :: [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)]
indList = ((([k1], [k1], [k2], [k2], [k3]), v)
 -> (IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v))
-> [(([k1], [k1], [k2], [k2], [k3]), v)]
-> [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)]
forall a b. (a -> b) -> [a] -> [b]
map (\(([k1]
x1,[k1]
x2,[k2]
x3,[k2]
x4,[k3]
x5),v
y) -> (([k1] -> IndList n1 k1
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k1]
x1, [k1] -> IndList n2 k1
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k1]
x2, [k2] -> IndList n3 k2
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k2]
x3, [k2] -> IndList n4 k2
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k2]
x4, [k3] -> IndList n5 k3
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k3]
x5),v
y)) [(([k1], [k1], [k2], [k2], [k3]), v)]
l

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
fromListT6 :: [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)]
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
fromListT6 [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)]
l = (AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> [AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v]
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
(&+) AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall (n :: Nat) k v. Tensor n k v
ZeroTensor [AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v]
tensList
    where
        tensList :: [AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v]
tensList = ((IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)]
-> [AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v]
forall a b. (a -> b) -> [a] -> [b]
map (IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) k1 k2 k3 v.
(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
mkTens6 [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)]
l

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
fromListT6' :: [(([k1], [k1], [k2], [k2], [k3], [k3]), v)]
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
fromListT6' [(([k1], [k1], [k2], [k2], [k3], [k3]), v)]
l = [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)]
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall k1 k2 k3 v (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat).
(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
fromListT6 [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)]
indList
        where
            indList :: [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)]
indList = ((([k1], [k1], [k2], [k2], [k3], [k3]), v)
 -> (IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v))
-> [(([k1], [k1], [k2], [k2], [k3], [k3]), v)]
-> [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)]
forall a b. (a -> b) -> [a] -> [b]
map (\(([k1]
x1,[k1]
x2,[k2]
x3,[k2]
x4,[k3]
x5,[k3]
x6),v
y) -> (([k1] -> IndList n1 k1
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k1]
x1, [k1] -> IndList n2 k1
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k1]
x2, [k2] -> IndList n3 k2
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k2]
x3, [k2] -> IndList n4 k2
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k2]
x4, [k3] -> IndList n5 k3
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k3]
x5, [k3] -> IndList n6 k3
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k3]
x6),v
y)) [(([k1], [k1], [k2], [k2], [k3], [k3]), v)]
l

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
fromListT7 :: [(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
fromListT7 [(IndTuple7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4, v)]
l = (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
 -> 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
-> [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
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr 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
-> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
(&+) AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
forall (n :: Nat) k v. Tensor n k v
ZeroTensor [AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v]
tensList
    where
        tensList :: [AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v]
tensList = ((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)
-> [(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]
forall a b. (a -> b) -> [a] -> [b]
map (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
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4 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
mkTens7 [(IndTuple7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4, v)]
l

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
fromListT7' :: [(([k1], [k1], [k2], [k2], [k3], [k3], [k4]), v)]
-> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
fromListT7' [(([k1], [k1], [k2], [k2], [k3], [k3], [k4]), v)]
l = [(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
forall k1 k2 k3 k4 v (n1 :: Nat) (n2 :: Nat) (n3 :: Nat)
       (n4 :: Nat) (n5 :: Nat) (n6 :: Nat) (n7 :: Nat).
(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
fromListT7 [(IndTuple7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4, v)]
indList
        where
            indList :: [(IndTuple7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4, v)]
indList = ((([k1], [k1], [k2], [k2], [k3], [k3], [k4]), v)
 -> (IndTuple7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4, v))
-> [(([k1], [k1], [k2], [k2], [k3], [k3], [k4]), v)]
-> [(IndTuple7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4, v)]
forall a b. (a -> b) -> [a] -> [b]
map (\(([k1]
x1,[k1]
x2,[k2]
x3,[k2]
x4,[k3]
x5,[k3]
x6,[k4]
x7),v
y) -> (([k1] -> IndList n1 k1
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k1]
x1, [k1] -> IndList n2 k1
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k1]
x2, [k2] -> IndList n3 k2
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k2]
x3, [k2] -> IndList n4 k2
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k2]
x4, [k3] -> IndList n5 k3
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k3]
x5, [k3] -> IndList n6 k3
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k3]
x6, [k4] -> IndList n7 k4
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k4]
x7),v
y)) [(([k1], [k1], [k2], [k2], [k3], [k3], [k4]), v)]
l

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
fromListT8 :: [(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
fromListT8 [(IndTuple8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4, v)]
l = (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
 -> 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
-> [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
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr 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
-> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
(&+) AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
forall (n :: Nat) k v. Tensor n k v
ZeroTensor [AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v]
tensList
    where
        tensList :: [AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v]
tensList = ((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)
-> [(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]
forall a b. (a -> b) -> [a] -> [b]
map (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
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) (n8 :: Nat) k1 k2 k3 k4 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
mkTens8 [(IndTuple8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4, v)]
l

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
fromListT8' :: [(([k1], [k1], [k2], [k2], [k3], [k3], [k4], [k4]), v)]
-> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
fromListT8' [(([k1], [k1], [k2], [k2], [k3], [k3], [k4], [k4]), v)]
l = [(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
forall k1 k2 k3 k4 v (n1 :: Nat) (n2 :: Nat) (n3 :: Nat)
       (n4 :: Nat) (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) (n8 :: Nat).
(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
fromListT8 [(IndTuple8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4, v)]
indList
        where
            indList :: [(IndTuple8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4, v)]
indList = ((([k1], [k1], [k2], [k2], [k3], [k3], [k4], [k4]), v)
 -> (IndTuple8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4, v))
-> [(([k1], [k1], [k2], [k2], [k3], [k3], [k4], [k4]), v)]
-> [(IndTuple8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4, v)]
forall a b. (a -> b) -> [a] -> [b]
map (\(([k1]
x1,[k1]
x2,[k2]
x3,[k2]
x4,[k3]
x5,[k3]
x6,[k4]
x7,[k4]
x8),v
y) -> (([k1] -> IndList n1 k1
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k1]
x1, [k1] -> IndList n2 k1
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k1]
x2, [k2] -> IndList n3 k2
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k2]
x3, [k2] -> IndList n4 k2
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k2]
x4, [k3] -> IndList n5 k3
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k3]
x5, [k3] -> IndList n6 k3
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k3]
x6, [k4] -> IndList n7 k4
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k4]
x7, [k4] -> IndList n8 k4
forall (n :: Nat) a. KnownNat n => [a] -> IndList n a
fromListUnsafe [k4]
x8),v
y)) [(([k1], [k1], [k2], [k2], [k3], [k3], [k4], [k4]), v)]
l


--helper function for tensor addition: adding one indices value pair to the tree structure of a given tensor

insertOrAdd :: (TIndex k, TAdd v) => (IndList n k, v) -> Tensor n k v -> Tensor n k v
insertOrAdd :: (IndList n k, v) -> Tensor n k v -> Tensor n k v
insertOrAdd (IndList n k
Empty, v
a) (Scalar v
b) = v -> Tensor 0 k v
forall v k. v -> Tensor 0 k v
Scalar (v -> Tensor 0 k v) -> v -> Tensor 0 k v
forall a b. (a -> b) -> a -> b
$ v
a v -> v -> v
forall a. TAdd a => a -> a -> a
`addS` v
b
insertOrAdd (IndList n k
_, v
_)     (Scalar v
_) = String -> Tensor n k v
forall a. HasCallStack => String -> a
error String
"cannot add key value pair to scalar"
insertOrAdd (Append k
x IndList (n - 1) k
xs, v
a) (Tensor TMap k (Tensor n k v)
m) = TMap k (Tensor n k v) -> Tensor (n + 1) k v
forall k (n :: Nat) v. TMap k (Tensor n k v) -> Tensor (n + 1) k v
Tensor (TMap k (Tensor n k v) -> Tensor (n + 1) k v)
-> TMap k (Tensor n k v) -> Tensor (n + 1) k v
forall a b. (a -> b) -> a -> b
$ (Tensor n k v -> Tensor n k v -> Tensor n k v)
-> k
-> Tensor n k v
-> TMap k (Tensor n k v)
-> TMap k (Tensor n k v)
forall k v.
Ord k =>
(v -> v -> v) -> k -> v -> TMap k v -> TMap k v
insertWithTMap (\Tensor n k v
_ Tensor n k v
o -> (IndList n k, v) -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(IndList n k, v) -> Tensor n k v -> Tensor n k v
insertOrAdd (IndList n k
IndList (n - 1) k
xs, v
a) Tensor n k v
o) k
x Tensor n k v
indTens TMap k (Tensor n k v)
m
            where
                indTens :: Tensor n k v
indTens = (IndList n k, v) -> Tensor n k v
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n k
IndList (n - 1) k
xs, v
a)
insertOrAdd (IndList n k, v)
inds Tensor n k v
ZeroTensor = (IndList n k, v) -> Tensor n k v
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n k, v)
inds

--addition for tensors

infixl 6 &+

-- | 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.

(&+) :: (TIndex k, TAdd v) => Tensor n k v -> Tensor n k v -> Tensor n k v
&+ :: Tensor n k v -> Tensor n k v -> Tensor n k v
(&+) (Scalar v
a) (Scalar v
b) = v -> Tensor 0 k v
forall v k. v -> Tensor 0 k v
Scalar (v -> Tensor 0 k v) -> v -> Tensor 0 k v
forall a b. (a -> b) -> a -> b
$ v
a v -> v -> v
forall a. TAdd a => a -> a -> a
`addS` v
b
(&+) (Tensor TMap k (Tensor n k v)
m1) (Tensor TMap k (Tensor n k v)
m2) = TMap k (Tensor n k v) -> Tensor (n + 1) k v
forall k (n :: Nat) v. TMap k (Tensor n k v) -> Tensor (n + 1) k v
Tensor (TMap k (Tensor n k v) -> Tensor (n + 1) k v)
-> TMap k (Tensor n k v) -> Tensor (n + 1) k v
forall a b. (a -> b) -> a -> b
$ (Tensor n k v -> Tensor n k v -> Tensor n k v)
-> TMap k (Tensor n k v)
-> TMap k (Tensor n k v)
-> TMap k (Tensor n k v)
forall k v.
Ord k =>
(v -> v -> v) -> TMap k v -> TMap k v -> TMap k v
addTMaps Tensor n k v -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
(&+) TMap k (Tensor n k v)
m1 TMap k (Tensor n k v)
TMap k (Tensor n k v)
m2
(&+) Tensor n k v
t1 Tensor n k v
ZeroTensor = Tensor n k v
t1
(&+) Tensor n k v
ZeroTensor Tensor n k v
t2 = Tensor n k v
t2
(&+) Tensor n k v
_ Tensor n k v
_ = String -> Tensor n k v
forall a. HasCallStack => String -> a
error String
"incompatible combination of summands"

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

infix 8 &.

(&.) :: (TIndex k, Prod s v) => s -> Tensor n k v -> Tensor n k (TProd s v)
&. :: s -> Tensor n k v -> Tensor n k (TProd s v)
(&.) s
scalar = (v -> TProd s v) -> Tensor n k v -> Tensor n k (TProd s v)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (s -> v -> TProd s v
forall v v'. Prod v v' => v -> v' -> TProd v v'
prod s
scalar)

-- | 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.

negateTens :: (TIndex k, TAdd v) => Tensor n k v -> Tensor n k v
negateTens :: Tensor n k v -> Tensor n k v
negateTens = (v -> v) -> Tensor n k v -> Tensor n k v
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap v -> v
forall a. TAdd a => a -> a
negateS

-- | Subtraction of two arbitrary @'Tensor'@s. 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.

infixl 6 &-

(&-) :: (TIndex k, TAdd v) => Tensor n k v -> Tensor n k v -> Tensor n k v
&- :: Tensor n k v -> Tensor n k v -> Tensor n k v
(&-) (Scalar v
a) (Scalar v
b) = v -> Tensor 0 k v
forall v k. v -> Tensor 0 k v
Scalar (v -> Tensor 0 k v) -> v -> Tensor 0 k v
forall a b. (a -> b) -> a -> b
$ v -> v -> v
forall a. TAdd a => a -> a -> a
subS v
a v
b
(&-) t1 :: Tensor n k v
t1@(Tensor TMap k (Tensor n k v)
_) t2 :: Tensor n k v
t2@(Tensor TMap k (Tensor n k v)
_) = Tensor n k v
t1 Tensor n k v -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
&+ (Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v
negateTens Tensor n k v
t2)
(&-) Tensor n k v
t1 Tensor n k v
ZeroTensor = Tensor n k v
t1
(&-) Tensor n k v
ZeroTensor Tensor n k v
t2 = Tensor n k v -> Tensor n k v
forall a. TAdd a => a -> a
negateS Tensor n k v
t2
(&-) Tensor n k v
_ Tensor n k v
_ = String -> Tensor n k v
forall a. HasCallStack => String -> a
error String
"incompatible combination of summands"

-- | Tensor product of two @'Tensor'@s. 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 @'Tensor'@s must satisfy the @'Prod'@ constraint.

infixl 7 &*

(&*) :: (TIndex k, Prod v v') => Tensor n k v -> Tensor m k v' -> TProd (Tensor n k v) (Tensor m k v')
&* :: Tensor n k v
-> Tensor m k v' -> TProd (Tensor n k v) (Tensor m k v')
(&*) (Scalar v
x) (Scalar v'
y) = TProd v v' -> Tensor 0 k (TProd v v')
forall v k. v -> Tensor 0 k v
Scalar (TProd v v' -> Tensor 0 k (TProd v v'))
-> TProd v v' -> Tensor 0 k (TProd v v')
forall a b. (a -> b) -> a -> b
$ v -> v' -> TProd v v'
forall v v'. Prod v v' => v -> v' -> TProd v v'
prod v
x v'
y
(&*) (Scalar v
x) Tensor m k v'
t2 = (v' -> TProd v v') -> Tensor m k v' -> Tensor m k (TProd v v')
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (v -> v' -> TProd v v'
forall v v'. Prod v v' => v -> v' -> TProd v v'
prod v
x) Tensor m k v'
t2
(&*) (Tensor TMap k (Tensor n k v)
m) Tensor m k v'
t2 = TMap k (Tensor (n + m) k (TProd v v'))
-> Tensor ((n + m) + 1) k (TProd v v')
forall k (n :: Nat) v. TMap k (Tensor n k v) -> Tensor (n + 1) k v
Tensor (TMap k (Tensor (n + m) k (TProd v v'))
 -> Tensor ((n + m) + 1) k (TProd v v'))
-> TMap k (Tensor (n + m) k (TProd v v'))
-> Tensor ((n + m) + 1) k (TProd v v')
forall a b. (a -> b) -> a -> b
$ (Tensor n k v -> Tensor (n + m) k (TProd v v'))
-> TMap k (Tensor n k v) -> TMap k (Tensor (n + m) k (TProd v v'))
forall v v' k. (v -> v') -> TMap k v -> TMap k v'
mapTMap (Tensor n k v
-> Tensor m k v' -> TProd (Tensor n k v) (Tensor m k v')
forall k v v' (n :: Nat) (n' :: Nat).
(TIndex k, Prod v v') =>
Tensor n k v
-> Tensor n' k v' -> TProd (Tensor n k v) (Tensor n' k v')
&* Tensor m k v'
t2) TMap k (Tensor n k v)
m
(&*) Tensor n k v
_ Tensor m k v'
ZeroTensor = TProd (Tensor n k v) (Tensor m k v')
forall (n :: Nat) k v. Tensor n k v
ZeroTensor
(&*) Tensor n k v
ZeroTensor Tensor m k v'
_ = TProd (Tensor n k v) (Tensor m k v')
forall (n :: Nat) k v. Tensor n k v
ZeroTensor

--encode and decode tensors as bytestrings for efficient storing

-- | Utility function to serialize and compress a @'Tensor'@ into a @'Data.ByteString.Lazy.ByteString'@, making use of the @'Serialize'@ instance.
encodeTensor :: (KnownNat n, Ord k, Serialize k, Serialize v) => Tensor n k v -> BS.ByteString
encodeTensor :: Tensor n k v -> ByteString
encodeTensor = ByteString -> ByteString
compress (ByteString -> ByteString)
-> (Tensor n k v -> ByteString) -> Tensor n k v -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tensor n k v -> ByteString
forall a. Serialize a => a -> ByteString
encodeLazy

-- | Utility function to decompress and de-serialize a @'Data.ByteString.Lazy.ByteString'@ into a @'Tensor'@, making use of the @'Serialize'@ instance.
decodeTensor :: (KnownNat n, Ord k, Serialize k, Serialize v) => BS.ByteString -> Either String (Tensor n k v)
decodeTensor :: ByteString -> Either String (Tensor n k v)
decodeTensor ByteString
bs = ByteString -> Either String (Tensor n k v)
forall a. Serialize a => ByteString -> Either String a
decodeLazy (ByteString -> Either String (Tensor n k v))
-> ByteString -> Either String (Tensor n k v)
forall a b. (a -> b) -> a -> b
$ ByteString -> ByteString
decompress ByteString
bs


-- | The function computes partial derivatives of spacetime tensors of type @'STTens'@ with @'CFun'@ values.
partial :: Num a => STTens n1 n2 (CFun [AD.Forward a] (AD.Forward a)) -> STTens n1 (n2+1) (CFun [a] a)
partial :: STTens n1 n2 (CFun [Forward a] (Forward a))
-> STTens n1 (n2 + 1) (CFun [a] a)
partial STTens n1 n2 (CFun [Forward a] (Forward a))
tens = STTens n1 (n2 + 1) (CFun [a] a)
tens'
    where
        tList :: [(IndTuple2 n1 n2 Ind3, CFun [Forward a] (Forward a))]
tList = STTens n1 n2 (CFun [Forward a] (Forward a))
-> [(IndTuple2 n1 n2 Ind3, CFun [Forward a] (Forward a))]
forall (n1 :: Nat) (n2 :: Nat) k1 v.
AbsTensor2 n1 n2 k1 v -> [(IndTuple2 n1 n2 k1, v)]
toListT2 STTens n1 n2 (CFun [Forward a] (Forward a))
tens
        grads :: [(IndTuple2 n1 n2 Ind3, [(Int, [a] -> a)])]
grads = ((IndTuple2 n1 n2 Ind3, CFun [Forward a] (Forward a))
 -> (IndTuple2 n1 n2 Ind3, [(Int, [a] -> a)]))
-> [(IndTuple2 n1 n2 Ind3, CFun [Forward a] (Forward a))]
-> [(IndTuple2 n1 n2 Ind3, [(Int, [a] -> a)])]
forall a b. (a -> b) -> [a] -> [b]
map (\(IndTuple2 n1 n2 Ind3
is, CFun [Forward a] -> Forward a
v) -> (IndTuple2 n1 n2 Ind3
is, [Int] -> ([Forward a] -> Forward a) -> [(Int, [a] -> a)]
forall a.
Num a =>
[Int] -> ([Forward a] -> Forward a) -> [(Int, [a] -> a)]
myGrad [Int
0..Int
3] [Forward a] -> Forward a
v)) [(IndTuple2 n1 n2 Ind3, CFun [Forward a] (Forward a))]
tList
        tList' :: [((IndList n1 Ind3, IndList (n2 + 1) Ind3), CFun [a] a)]
tList' = ((IndTuple2 n1 n2 Ind3, [(Int, [a] -> a)])
 -> [((IndList n1 Ind3, IndList (n2 + 1) Ind3), CFun [a] a)])
-> [(IndTuple2 n1 n2 Ind3, [(Int, [a] -> a)])]
-> [((IndList n1 Ind3, IndList (n2 + 1) Ind3), CFun [a] a)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 Ind3
i1, IndList n2 Ind3
i2), [(Int, [a] -> a)]
gs) -> ((Int, [a] -> a)
 -> ((IndList n1 Ind3, IndList (n2 + 1) Ind3), CFun [a] a))
-> [(Int, [a] -> a)]
-> [((IndList n1 Ind3, IndList (n2 + 1) Ind3), CFun [a] a)]
forall a b. (a -> b) -> [a] -> [b]
map (\(Int
ig, [a] -> a
g) -> ((IndList n1 Ind3
i1, Int -> Ind3
Ind3 Int
ig Ind3 -> IndList ((n2 + 1) - 1) Ind3 -> IndList (n2 + 1) Ind3
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
`Append` IndList n2 Ind3
IndList ((n2 + 1) - 1) Ind3
i2), ([a] -> a) -> CFun [a] a
forall a b. (a -> b) -> CFun a b
CFun [a] -> a
g)) [(Int, [a] -> a)]
gs) [(IndTuple2 n1 n2 Ind3, [(Int, [a] -> a)])]
grads
        tens' :: STTens n1 (n2 + 1) (CFun [a] a)
tens' = [((IndList n1 Ind3, IndList (n2 + 1) Ind3), CFun [a] a)]
-> STTens n1 (n2 + 1) (CFun [a] a)
forall k1 v (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd v) =>
[(IndTuple2 n1 n2 k1, v)] -> AbsTensor2 n1 n2 k1 v
fromListT2 [((IndList n1 Ind3, IndList (n2 + 1) Ind3), CFun [a] a)]
tList'

-- | The function computes partial derivatives of spacetime tensors of type @'STTens'@ with @'SSymbolic'@ values.
--
-- > g_ab_p = partialSymbolic ["t", "x", "y", "z"] g_ab

partialSymbolic :: [String] -> STTens n1 n2 SSymbolic -> STTens n1 (n2+1) SSymbolic
partialSymbolic :: [String] -> STTens n1 n2 SSymbolic -> STTens n1 (n2 + 1) SSymbolic
partialSymbolic [String]
vars STTens n1 n2 SSymbolic
tens = STTens n1 (n2 + 1) SSymbolic
tens'
    where
        tList :: [(IndTuple2 n1 n2 Ind3, SSymbolic)]
tList = STTens n1 n2 SSymbolic -> [(IndTuple2 n1 n2 Ind3, SSymbolic)]
forall (n1 :: Nat) (n2 :: Nat) k1 v.
AbsTensor2 n1 n2 k1 v -> [(IndTuple2 n1 n2 k1, v)]
toListT2 STTens n1 n2 SSymbolic
tens
        grads :: [(IndTuple2 n1 n2 Ind3, [(Int, SSymbolic)])]
grads = ((IndTuple2 n1 n2 Ind3, SSymbolic)
 -> (IndTuple2 n1 n2 Ind3, [(Int, SSymbolic)]))
-> [(IndTuple2 n1 n2 Ind3, SSymbolic)]
-> [(IndTuple2 n1 n2 Ind3, [(Int, SSymbolic)])]
forall a b. (a -> b) -> [a] -> [b]
map (\(IndTuple2 n1 n2 Ind3
is, SSymbolic String
v) -> (IndTuple2 n1 n2 Ind3
is, ((Int, String) -> (Int, SSymbolic))
-> [(Int, String)] -> [(Int, SSymbolic)]
forall a b. (a -> b) -> [a] -> [b]
map (\(Int
i, String
var) -> (Int
i, String -> SSymbolic
SSymbolic (String -> SSymbolic) -> String -> SSymbolic
forall a b. (a -> b) -> a -> b
$ String
"diff(" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
v String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
", " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
var String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")")) ([(Int, String)] -> [(Int, SSymbolic)])
-> [(Int, String)] -> [(Int, SSymbolic)]
forall a b. (a -> b) -> a -> b
$ [Int] -> [String] -> [(Int, String)]
forall a b. [a] -> [b] -> [(a, b)]
zip [Int
0..] [String]
vars)) [(IndTuple2 n1 n2 Ind3, SSymbolic)]
tList
        tList' :: [((IndList n1 Ind3, IndList (n2 + 1) Ind3), SSymbolic)]
tList' = ((IndTuple2 n1 n2 Ind3, [(Int, SSymbolic)])
 -> [((IndList n1 Ind3, IndList (n2 + 1) Ind3), SSymbolic)])
-> [(IndTuple2 n1 n2 Ind3, [(Int, SSymbolic)])]
-> [((IndList n1 Ind3, IndList (n2 + 1) Ind3), SSymbolic)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 Ind3
i1, IndList n2 Ind3
i2), [(Int, SSymbolic)]
gs) -> ((Int, SSymbolic)
 -> ((IndList n1 Ind3, IndList (n2 + 1) Ind3), SSymbolic))
-> [(Int, SSymbolic)]
-> [((IndList n1 Ind3, IndList (n2 + 1) Ind3), SSymbolic)]
forall a b. (a -> b) -> [a] -> [b]
map (\(Int
ig, SSymbolic
g) -> ((IndList n1 Ind3
i1, Int -> Ind3
Ind3 Int
ig Ind3 -> IndList ((n2 + 1) - 1) Ind3 -> IndList (n2 + 1) Ind3
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
`Append` IndList n2 Ind3
IndList ((n2 + 1) - 1) Ind3
i2), SSymbolic
g)) [(Int, SSymbolic)]
gs) [(IndTuple2 n1 n2 Ind3, [(Int, SSymbolic)])]
grads
        tens' :: STTens n1 (n2 + 1) SSymbolic
tens' = [((IndList n1 Ind3, IndList (n2 + 1) Ind3), SSymbolic)]
-> STTens n1 (n2 + 1) SSymbolic
forall k1 v (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd v) =>
[(IndTuple2 n1 n2 k1, v)] -> AbsTensor2 n1 n2 k1 v
fromListT2 [((IndList n1 Ind3, IndList (n2 + 1) Ind3), SSymbolic)]
tList'

--AbsTensors automatically satisfy TensorAlgebra as we only used type synonyms
--e.g. AbsTensor4 actually looks like Tensor n1 kq1 (Tensor n2 k2 (Tensor n3 k3 (Tensor n4 k4 (Tensor n5 k5 (Tensor n6 k6 (Tensor n7 k7 (Tensor n8 k8 a)))))))

--fmap takes us 1 level deeper -> we get functions that apply a given function to the various sub tensors

-- | Synonym for @fmap@. @'mapTo1'@ applies a function to the values of a tensor.
--
-- > mapTo1 = fmap
mapTo1 :: (v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 :: (v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 = (v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap

-- | 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 @'Tensor'@s.
--
-- > mapTo2 = fmap . fmap
mapTo2 :: (v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 :: (v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 = (Tensor n2 k v1 -> Tensor n2 k v2)
-> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n2 k v1 -> Tensor n2 k v2)
 -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2)
-> ((v1 -> v2) -> Tensor n2 k v1 -> Tensor n2 k v2)
-> (v1 -> v2)
-> Tensor2 n1 n2 k v1
-> Tensor2 n1 n2 k v2
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (v1 -> v2) -> Tensor n2 k v1 -> Tensor n2 k v2
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap

-- | Maps a function to the 3rd leaf level.
--
-- > mapTo3 = fmap . fmap . fmap
mapTo3 :: (v1 -> v2) -> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 :: (v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 = (Tensor n2 k1 (Tensor n3 k2 v1) -> Tensor n2 k1 (Tensor n3 k2 v2))
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n2 k1 (Tensor n3 k2 v1) -> Tensor n2 k1 (Tensor n3 k2 v2))
 -> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2)
-> ((v1 -> v2)
    -> Tensor n2 k1 (Tensor n3 k2 v1)
    -> Tensor n2 k1 (Tensor n3 k2 v2))
-> (v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1
-> AbsTensor3 n1 n2 n3 k1 k2 v2
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n3 k2 v1 -> Tensor n3 k2 v2)
-> Tensor n2 k1 (Tensor n3 k2 v1) -> Tensor n2 k1 (Tensor n3 k2 v2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n3 k2 v1 -> Tensor n3 k2 v2)
 -> Tensor n2 k1 (Tensor n3 k2 v1)
 -> Tensor n2 k1 (Tensor n3 k2 v2))
-> ((v1 -> v2) -> Tensor n3 k2 v1 -> Tensor n3 k2 v2)
-> (v1 -> v2)
-> Tensor n2 k1 (Tensor n3 k2 v1)
-> Tensor n2 k1 (Tensor n3 k2 v2)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (v1 -> v2) -> Tensor n3 k2 v1 -> Tensor n3 k2 v2
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap

-- | Maps a function to the 4th leaf level.
--
-- > mapTo4 = fmap . fmap . fmap . fmap
mapTo4 :: (v1 -> v2) -> AbsTensor4 n1 n2 n3 n4 k1 k2 v1 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 :: (v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 = (Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v1))
 -> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v2)))
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v1))
  -> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v2)))
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v2)
-> ((v1 -> v2)
    -> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v1))
    -> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v2)))
-> (v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n3 k2 (Tensor n4 k2 v1) -> Tensor n3 k2 (Tensor n4 k2 v2))
-> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v1))
-> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v2))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n3 k2 (Tensor n4 k2 v1) -> Tensor n3 k2 (Tensor n4 k2 v2))
 -> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v1))
 -> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v2)))
-> ((v1 -> v2)
    -> Tensor n3 k2 (Tensor n4 k2 v1)
    -> Tensor n3 k2 (Tensor n4 k2 v2))
-> (v1 -> v2)
-> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v1))
-> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v2))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n4 k2 v1 -> Tensor n4 k2 v2)
-> Tensor n3 k2 (Tensor n4 k2 v1) -> Tensor n3 k2 (Tensor n4 k2 v2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n4 k2 v1 -> Tensor n4 k2 v2)
 -> Tensor n3 k2 (Tensor n4 k2 v1)
 -> Tensor n3 k2 (Tensor n4 k2 v2))
-> ((v1 -> v2) -> Tensor n4 k2 v1 -> Tensor n4 k2 v2)
-> (v1 -> v2)
-> Tensor n3 k2 (Tensor n4 k2 v1)
-> Tensor n3 k2 (Tensor n4 k2 v2)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (v1 -> v2) -> Tensor n4 k2 v1 -> Tensor n4 k2 v2
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap

-- | Maps a function to the 5th leaf level.
--
-- > mapTo5 = fmap . 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
mapTo5 :: (v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 = (Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v1)))
 -> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v2))))
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v1)))
  -> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v2))))
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2)
-> ((v1 -> v2)
    -> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v1)))
    -> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v2))))
-> (v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v1))
 -> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v2)))
-> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v1)))
-> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v2)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v1))
  -> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v2)))
 -> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v1)))
 -> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v2))))
-> ((v1 -> v2)
    -> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v1))
    -> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v2)))
-> (v1 -> v2)
-> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v1)))
-> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v2)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n4 k2 (Tensor n5 k3 v1) -> Tensor n4 k2 (Tensor n5 k3 v2))
-> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v1))
-> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v2))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n4 k2 (Tensor n5 k3 v1) -> Tensor n4 k2 (Tensor n5 k3 v2))
 -> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v1))
 -> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v2)))
-> ((v1 -> v2)
    -> Tensor n4 k2 (Tensor n5 k3 v1)
    -> Tensor n4 k2 (Tensor n5 k3 v2))
-> (v1 -> v2)
-> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v1))
-> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v2))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n5 k3 v1 -> Tensor n5 k3 v2)
-> Tensor n4 k2 (Tensor n5 k3 v1) -> Tensor n4 k2 (Tensor n5 k3 v2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n5 k3 v1 -> Tensor n5 k3 v2)
 -> Tensor n4 k2 (Tensor n5 k3 v1)
 -> Tensor n4 k2 (Tensor n5 k3 v2))
-> ((v1 -> v2) -> Tensor n5 k3 v1 -> Tensor n5 k3 v2)
-> (v1 -> v2)
-> Tensor n4 k2 (Tensor n5 k3 v1)
-> Tensor n4 k2 (Tensor n5 k3 v2)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (v1 -> v2) -> Tensor n5 k3 v1 -> Tensor n5 k3 v2
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap

-- | Maps a function to the 6th leaf level.
--
-- > mapTo6 = fmap . 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
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
mapTo6 = (Tensor
   n2
   k1
   (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v1))))
 -> Tensor
      n2
      k1
      (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v2)))))
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor
    n2
    k1
    (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v1))))
  -> Tensor
       n2
       k1
       (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v2)))))
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2)
-> ((v1 -> v2)
    -> Tensor
         n2
         k1
         (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v1))))
    -> Tensor
         n2
         k1
         (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v2)))))
-> (v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v1)))
 -> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v2))))
-> Tensor
     n2
     k1
     (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v1))))
-> Tensor
     n2
     k1
     (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v2))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v1)))
  -> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v2))))
 -> Tensor
      n2
      k1
      (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v1))))
 -> Tensor
      n2
      k1
      (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v2)))))
-> ((v1 -> v2)
    -> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v1)))
    -> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v2))))
-> (v1 -> v2)
-> Tensor
     n2
     k1
     (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v1))))
-> Tensor
     n2
     k1
     (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v2))))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v1))
 -> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v2)))
-> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v1)))
-> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v2)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v1))
  -> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v2)))
 -> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v1)))
 -> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v2))))
-> ((v1 -> v2)
    -> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v1))
    -> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v2)))
-> (v1 -> v2)
-> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v1)))
-> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v2)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n5 k3 (Tensor n6 k3 v1) -> Tensor n5 k3 (Tensor n6 k3 v2))
-> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v1))
-> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v2))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n5 k3 (Tensor n6 k3 v1) -> Tensor n5 k3 (Tensor n6 k3 v2))
 -> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v1))
 -> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v2)))
-> ((v1 -> v2)
    -> Tensor n5 k3 (Tensor n6 k3 v1)
    -> Tensor n5 k3 (Tensor n6 k3 v2))
-> (v1 -> v2)
-> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v1))
-> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v2))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n6 k3 v1 -> Tensor n6 k3 v2)
-> Tensor n5 k3 (Tensor n6 k3 v1) -> Tensor n5 k3 (Tensor n6 k3 v2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n6 k3 v1 -> Tensor n6 k3 v2)
 -> Tensor n5 k3 (Tensor n6 k3 v1)
 -> Tensor n5 k3 (Tensor n6 k3 v2))
-> ((v1 -> v2) -> Tensor n6 k3 v1 -> Tensor n6 k3 v2)
-> (v1 -> v2)
-> Tensor n5 k3 (Tensor n6 k3 v1)
-> Tensor n5 k3 (Tensor n6 k3 v2)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (v1 -> v2) -> Tensor n6 k3 v1 -> Tensor n6 k3 v2
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap

-- | Maps a function to the 7th leaf level.
--
-- > mapTo7 = fmap . 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
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
mapTo7 = (Tensor
   n2
   k1
   (Tensor
      n3
      k2
      (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1)))))
 -> Tensor
      n2
      k1
      (Tensor
         n3
         k2
         (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 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
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor
    n2
    k1
    (Tensor
       n3
       k2
       (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1)))))
  -> Tensor
       n2
       k1
       (Tensor
          n3
          k2
          (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 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)
-> ((v1 -> v2)
    -> Tensor
         n2
         k1
         (Tensor
            n3
            k2
            (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1)))))
    -> Tensor
         n2
         k1
         (Tensor
            n3
            k2
            (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2))))))
-> (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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor
   n3
   k2
   (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1))))
 -> Tensor
      n3
      k2
      (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2)))))
-> Tensor
     n2
     k1
     (Tensor
        n3
        k2
        (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1)))))
-> Tensor
     n2
     k1
     (Tensor
        n3
        k2
        (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2)))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor
    n3
    k2
    (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1))))
  -> Tensor
       n3
       k2
       (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2)))))
 -> Tensor
      n2
      k1
      (Tensor
         n3
         k2
         (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1)))))
 -> Tensor
      n2
      k1
      (Tensor
         n3
         k2
         (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2))))))
-> ((v1 -> v2)
    -> Tensor
         n3
         k2
         (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1))))
    -> Tensor
         n3
         k2
         (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2)))))
-> (v1 -> v2)
-> Tensor
     n2
     k1
     (Tensor
        n3
        k2
        (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1)))))
-> Tensor
     n2
     k1
     (Tensor
        n3
        k2
        (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2)))))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1)))
 -> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2))))
-> Tensor
     n3
     k2
     (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1))))
-> Tensor
     n3
     k2
     (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1)))
  -> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2))))
 -> Tensor
      n3
      k2
      (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1))))
 -> Tensor
      n3
      k2
      (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2)))))
-> ((v1 -> v2)
    -> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1)))
    -> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2))))
-> (v1 -> v2)
-> Tensor
     n3
     k2
     (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1))))
-> Tensor
     n3
     k2
     (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2))))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1))
 -> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2)))
-> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1)))
-> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1))
  -> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2)))
 -> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1)))
 -> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2))))
-> ((v1 -> v2)
    -> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1))
    -> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2)))
-> (v1 -> v2)
-> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1)))
-> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n6 k3 (Tensor n7 k4 v1) -> Tensor n6 k3 (Tensor n7 k4 v2))
-> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1))
-> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n6 k3 (Tensor n7 k4 v1) -> Tensor n6 k3 (Tensor n7 k4 v2))
 -> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1))
 -> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2)))
-> ((v1 -> v2)
    -> Tensor n6 k3 (Tensor n7 k4 v1)
    -> Tensor n6 k3 (Tensor n7 k4 v2))
-> (v1 -> v2)
-> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v1))
-> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v2))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n7 k4 v1 -> Tensor n7 k4 v2)
-> Tensor n6 k3 (Tensor n7 k4 v1) -> Tensor n6 k3 (Tensor n7 k4 v2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n7 k4 v1 -> Tensor n7 k4 v2)
 -> Tensor n6 k3 (Tensor n7 k4 v1)
 -> Tensor n6 k3 (Tensor n7 k4 v2))
-> ((v1 -> v2) -> Tensor n7 k4 v1 -> Tensor n7 k4 v2)
-> (v1 -> v2)
-> Tensor n6 k3 (Tensor n7 k4 v1)
-> Tensor n6 k3 (Tensor n7 k4 v2)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (v1 -> v2) -> Tensor n7 k4 v1 -> Tensor n7 k4 v2
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap

-- | Maps a function to the 8th leaf level.
--
-- > mapTo8 = fmap . 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
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
mapTo8 = (Tensor
   n2
   k1
   (Tensor
      n3
      k2
      (Tensor
         n4
         k2
         (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1))))))
 -> Tensor
      n2
      k1
      (Tensor
         n3
         k2
         (Tensor
            n4
            k2
            (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 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
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor
    n2
    k1
    (Tensor
       n3
       k2
       (Tensor
          n4
          k2
          (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1))))))
  -> Tensor
       n2
       k1
       (Tensor
          n3
          k2
          (Tensor
             n4
             k2
             (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 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)
-> ((v1 -> v2)
    -> Tensor
         n2
         k1
         (Tensor
            n3
            k2
            (Tensor
               n4
               k2
               (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1))))))
    -> Tensor
         n2
         k1
         (Tensor
            n3
            k2
            (Tensor
               n4
               k2
               (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2)))))))
-> (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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor
   n3
   k2
   (Tensor
      n4
      k2
      (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1)))))
 -> Tensor
      n3
      k2
      (Tensor
         n4
         k2
         (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2))))))
-> Tensor
     n2
     k1
     (Tensor
        n3
        k2
        (Tensor
           n4
           k2
           (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1))))))
-> Tensor
     n2
     k1
     (Tensor
        n3
        k2
        (Tensor
           n4
           k2
           (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2))))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor
    n3
    k2
    (Tensor
       n4
       k2
       (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1)))))
  -> Tensor
       n3
       k2
       (Tensor
          n4
          k2
          (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2))))))
 -> Tensor
      n2
      k1
      (Tensor
         n3
         k2
         (Tensor
            n4
            k2
            (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1))))))
 -> Tensor
      n2
      k1
      (Tensor
         n3
         k2
         (Tensor
            n4
            k2
            (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2)))))))
-> ((v1 -> v2)
    -> Tensor
         n3
         k2
         (Tensor
            n4
            k2
            (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1)))))
    -> Tensor
         n3
         k2
         (Tensor
            n4
            k2
            (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2))))))
-> (v1 -> v2)
-> Tensor
     n2
     k1
     (Tensor
        n3
        k2
        (Tensor
           n4
           k2
           (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1))))))
-> Tensor
     n2
     k1
     (Tensor
        n3
        k2
        (Tensor
           n4
           k2
           (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2))))))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor
   n4
   k2
   (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1))))
 -> Tensor
      n4
      k2
      (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2)))))
-> Tensor
     n3
     k2
     (Tensor
        n4
        k2
        (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1)))))
-> Tensor
     n3
     k2
     (Tensor
        n4
        k2
        (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2)))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor
    n4
    k2
    (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1))))
  -> Tensor
       n4
       k2
       (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2)))))
 -> Tensor
      n3
      k2
      (Tensor
         n4
         k2
         (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1)))))
 -> Tensor
      n3
      k2
      (Tensor
         n4
         k2
         (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2))))))
-> ((v1 -> v2)
    -> Tensor
         n4
         k2
         (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1))))
    -> Tensor
         n4
         k2
         (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2)))))
-> (v1 -> v2)
-> Tensor
     n3
     k2
     (Tensor
        n4
        k2
        (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1)))))
-> Tensor
     n3
     k2
     (Tensor
        n4
        k2
        (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2)))))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1)))
 -> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2))))
-> Tensor
     n4
     k2
     (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1))))
-> Tensor
     n4
     k2
     (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1)))
  -> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2))))
 -> Tensor
      n4
      k2
      (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1))))
 -> Tensor
      n4
      k2
      (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2)))))
-> ((v1 -> v2)
    -> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1)))
    -> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2))))
-> (v1 -> v2)
-> Tensor
     n4
     k2
     (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1))))
-> Tensor
     n4
     k2
     (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2))))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1))
 -> Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2)))
-> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1)))
-> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1))
  -> Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2)))
 -> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1)))
 -> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2))))
-> ((v1 -> v2)
    -> Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1))
    -> Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2)))
-> (v1 -> v2)
-> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1)))
-> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n7 k4 (Tensor n8 k4 v1) -> Tensor n7 k4 (Tensor n8 k4 v2))
-> Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1))
-> Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n7 k4 (Tensor n8 k4 v1) -> Tensor n7 k4 (Tensor n8 k4 v2))
 -> Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1))
 -> Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2)))
-> ((v1 -> v2)
    -> Tensor n7 k4 (Tensor n8 k4 v1)
    -> Tensor n7 k4 (Tensor n8 k4 v2))
-> (v1 -> v2)
-> Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v1))
-> Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v2))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n8 k4 v1 -> Tensor n8 k4 v2)
-> Tensor n7 k4 (Tensor n8 k4 v1) -> Tensor n7 k4 (Tensor n8 k4 v2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Tensor n8 k4 v1 -> Tensor n8 k4 v2)
 -> Tensor n7 k4 (Tensor n8 k4 v1)
 -> Tensor n7 k4 (Tensor n8 k4 v2))
-> ((v1 -> v2) -> Tensor n8 k4 v1 -> Tensor n8 k4 v2)
-> (v1 -> v2)
-> Tensor n7 k4 (Tensor n8 k4 v1)
-> Tensor n7 k4 (Tensor n8 k4 v2)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (v1 -> v2) -> Tensor n8 k4 v1 -> Tensor n8 k4 v2
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap

--remove Zero Values at every level of Abstract Tensor

-- | 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.
removeZeros :: TAdd v => Tensor n k v -> Tensor n k v
removeZeros :: Tensor n k v -> Tensor n k v
removeZeros (Scalar v
x) = if v -> Bool
forall a. TAdd a => a -> Bool
scaleZero v
x then Tensor n k v
forall (n :: Nat) k v. Tensor n k v
ZeroTensor else v -> Tensor 0 k v
forall v k. v -> Tensor 0 k v
Scalar v
x
removeZeros (Tensor TMap k (Tensor n k v)
m) = let newMap :: TMap k (Tensor n k v)
newMap = (Tensor n k v -> Bool)
-> TMap k (Tensor n k v) -> TMap k (Tensor n k v)
forall v k. (v -> Bool) -> TMap k v -> TMap k v
filterTMap
                                (\case
                                    Tensor n k v
ZeroTensor -> Bool
False
                                    Tensor n k v
_          -> Bool
True) (TMap k (Tensor n k v) -> TMap k (Tensor n k v))
-> TMap k (Tensor n k v) -> TMap k (Tensor n k v)
forall a b. (a -> b) -> a -> b
$ (Tensor n k v -> Tensor n k v)
-> TMap k (Tensor n k v) -> TMap k (Tensor n k v)
forall v v' k. (v -> v') -> TMap k v -> TMap k v'
mapTMap Tensor n k v -> Tensor n k v
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros TMap k (Tensor n k v)
m in if TMap k (Tensor n k v) -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null TMap k (Tensor n k v)
newMap then Tensor n k v
forall (n :: Nat) k v. Tensor n k v
ZeroTensor else TMap k (Tensor n k v) -> Tensor (n + 1) k v
forall k (n :: Nat) v. TMap k (Tensor n k v) -> Tensor (n + 1) k v
Tensor TMap k (Tensor n k v)
newMap
removeZeros Tensor n k v
ZeroTensor = Tensor n k v
forall (n :: Nat) k v. Tensor n k v
ZeroTensor

-- | >  removeZeros1 = removeZeros
removeZeros1 :: (TAdd v, TIndex k) => AbsTensor1 n1 k v -> AbsTensor1 n1 k v
removeZeros1 :: AbsTensor1 n1 k v -> AbsTensor1 n1 k v
removeZeros1 = AbsTensor1 n1 k v -> AbsTensor1 n1 k v
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros

-- | > removeZeros2 = removeZeros . mapTo1 removeZeros
removeZeros2 :: (TAdd v, TIndex k) => AbsTensor2 n1 n2 k v -> AbsTensor2 n1 n2 k v
removeZeros2 :: AbsTensor2 n1 n2 k v -> AbsTensor2 n1 n2 k v
removeZeros2 = AbsTensor2 n1 n2 k v -> AbsTensor2 n1 n2 k v
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (AbsTensor2 n1 n2 k v -> AbsTensor2 n1 n2 k v)
-> (AbsTensor2 n1 n2 k v -> AbsTensor2 n1 n2 k v)
-> AbsTensor2 n1 n2 k v
-> AbsTensor2 n1 n2 k v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n2 k v -> Tensor n2 k v)
-> AbsTensor2 n1 n2 k v -> AbsTensor2 n1 n2 k v
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 Tensor n2 k v -> Tensor n2 k v
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros

-- | > removeZeros3 = removeZeros . mapTo1 removeZeros . mapTo2 removeZeros
removeZeros3 :: (TAdd v, TIndex k1, TIndex k2) => AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
removeZeros3 :: AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
removeZeros3 = AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v)
-> (AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v)
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n2 k1 (Tensor n3 k2 v) -> Tensor n2 k1 (Tensor n3 k2 v))
-> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 Tensor n2 k1 (Tensor n3 k2 v) -> Tensor n2 k1 (Tensor n3 k2 v)
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v)
-> (AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v)
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n3 k2 v -> Tensor n3 k2 v)
-> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 Tensor n3 k2 v -> Tensor n3 k2 v
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros

-- | > removeZeros4 = removeZeros . mapTo1 removeZeros . mapTo2 removeZeros . mapTo3 removeZeros
removeZeros4 :: (TAdd v, TIndex k1, TIndex k2) => AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
removeZeros4 :: AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
removeZeros4 = AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v)
-> (AbsTensor4 n1 n2 n3 n4 k1 k2 v
    -> AbsTensor4 n1 n2 n3 n4 k1 k2 v)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v))
 -> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v)))
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v))
-> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v))
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v)
-> (AbsTensor4 n1 n2 n3 n4 k1 k2 v
    -> AbsTensor4 n1 n2 n3 n4 k1 k2 v)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n3 k2 (Tensor n4 k2 v) -> Tensor n3 k2 (Tensor n4 k2 v))
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 Tensor n3 k2 (Tensor n4 k2 v) -> Tensor n3 k2 (Tensor n4 k2 v)
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v)
-> (AbsTensor4 n1 n2 n3 n4 k1 k2 v
    -> AbsTensor4 n1 n2 n3 n4 k1 k2 v)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n4 k2 v -> Tensor n4 k2 v)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 Tensor n4 k2 v -> Tensor n4 k2 v
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros

-- | > removeZeros5 = removeZeros . mapTo1 removeZeros . mapTo2 removeZeros . mapTo3 removeZeros . mapTo4 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
removeZeros5 :: AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
removeZeros5 = AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v)
-> (AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
    -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))
 -> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v))))
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))
-> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v)
-> (AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
    -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v))
 -> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v))
-> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v))
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v)
-> (AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
    -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n4 k2 (Tensor n5 k3 v) -> Tensor n4 k2 (Tensor n5 k3 v))
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 Tensor n4 k2 (Tensor n5 k3 v) -> Tensor n4 k2 (Tensor n5 k3 v)
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v)
-> (AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
    -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n5 k3 v -> Tensor n5 k3 v)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 Tensor n5 k3 v -> Tensor n5 k3 v
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros

-- | > removeZeros6 = removeZeros . mapTo1 removeZeros . mapTo2 removeZeros . mapTo3 removeZeros . mapTo4 removeZeros . mapTo5 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
removeZeros6 :: AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
removeZeros6 = AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> (AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
    -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor
   n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))
 -> Tensor
      n2
      k1
      (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))))
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 Tensor
  n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))
-> Tensor
     n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> (AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
    -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))
 -> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))
-> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> (AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
    -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))
 -> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))
-> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> (AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
    -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n5 k3 (Tensor n6 k3 v) -> Tensor n5 k3 (Tensor n6 k3 v))
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 Tensor n5 k3 (Tensor n6 k3 v) -> Tensor n5 k3 (Tensor n6 k3 v)
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> (AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
    -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n6 k3 v -> Tensor n6 k3 v)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 Tensor n6 k3 v -> Tensor n6 k3 v
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros

-- | > removeZeros7 = removeZeros . mapTo1 removeZeros . mapTo2 removeZeros . mapTo3 removeZeros . mapTo4 removeZeros . mapTo5 removeZeros . mapTo6 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
removeZeros7 :: 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
removeZeros7 = 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
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (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)
-> (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)
-> 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor
   n2
   k1
   (Tensor
      n3
      k2
      (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))
 -> Tensor
      n2
      k1
      (Tensor
         n3
         k2
         (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))))
-> 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
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 Tensor
  n2
  k1
  (Tensor
     n3
     k2
     (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))
-> Tensor
     n2
     k1
     (Tensor
        n3
        k2
        (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (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)
-> (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)
-> 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor
   n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))
 -> Tensor
      n3
      k2
      (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 Tensor
  n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))
-> Tensor
     n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (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)
-> (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)
-> 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))
 -> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))
-> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (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)
-> (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)
-> 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))
 -> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))
-> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (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)
-> (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)
-> 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n6 k3 (Tensor n7 k4 v) -> Tensor n6 k3 (Tensor n7 k4 v))
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 Tensor n6 k3 (Tensor n7 k4 v) -> Tensor n6 k3 (Tensor n7 k4 v)
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (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)
-> (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)
-> 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n7 k4 v -> Tensor n7 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 Tensor n7 k4 v -> Tensor n7 k4 v
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros

-- | > removeZeros8 = removeZeros . mapTo1 removeZeros . mapTo2 removeZeros . mapTo3 removeZeros . mapTo4 removeZeros . mapTo5 removeZeros . mapTo6 removeZeros . mapTo7 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
removeZeros8 :: 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
removeZeros8 = 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
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (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)
-> (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)
-> 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor
   n2
   k1
   (Tensor
      n3
      k2
      (Tensor
         n4
         k2
         (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))
 -> Tensor
      n2
      k1
      (Tensor
         n3
         k2
         (Tensor
            n4
            k2
            (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))))
-> 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
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 Tensor
  n2
  k1
  (Tensor
     n3
     k2
     (Tensor
        n4
        k2
        (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))
-> Tensor
     n2
     k1
     (Tensor
        n3
        k2
        (Tensor
           n4
           k2
           (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (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)
-> (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)
-> 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor
   n3
   k2
   (Tensor
      n4
      k2
      (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))
 -> Tensor
      n3
      k2
      (Tensor
         n4
         k2
         (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 Tensor
  n3
  k2
  (Tensor
     n4
     k2
     (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))
-> Tensor
     n3
     k2
     (Tensor
        n4
        k2
        (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (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)
-> (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)
-> 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor
   n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))
 -> Tensor
      n4
      k2
      (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 Tensor
  n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))
-> Tensor
     n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (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)
-> (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)
-> 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))
 -> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))
-> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (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)
-> (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)
-> 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))
 -> Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))
-> Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (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)
-> (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)
-> 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n7 k4 (Tensor n8 k4 v) -> Tensor n7 k4 (Tensor n8 k4 v))
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 Tensor n7 k4 (Tensor n8 k4 v) -> Tensor n7 k4 (Tensor n8 k4 v)
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros (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)
-> (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)
-> 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tensor n8 k4 v -> Tensor n8 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4.
(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
mapTo7 Tensor n8 k4 v -> Tensor n8 k4 v
forall v (n :: Nat) k. TAdd v => Tensor n k v -> Tensor n k v
removeZeros


-- | 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.
tensorTrans :: (TIndex k, TAdd v) => (Int,Int) -> Tensor n k v -> Tensor n k v
tensorTrans :: (Int, Int) -> Tensor n k v -> Tensor n k v
tensorTrans (Int
0, Int
j) Tensor n k v
t = [(IndList n k, v)] -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[(IndList n k, v)] -> Tensor n k v
fromListT [(IndList n k, v)]
l
                where
                    l :: [(IndList n k, v)]
l = ((IndList n k, v) -> (IndList n k, v))
-> [(IndList n k, v)] -> [(IndList n k, v)]
forall a b. (a -> b) -> [a] -> [b]
map (\(IndList n k
x,v
y) -> (Int -> IndList n k -> IndList n k
forall (n :: Nat) b. Int -> IndList n b -> IndList n b
swapHead Int
j IndList n k
x, v
y)) ([(IndList n k, v)] -> [(IndList n k, v)])
-> [(IndList n k, v)] -> [(IndList n k, v)]
forall a b. (a -> b) -> a -> b
$ Tensor n k v -> [(IndList n k, v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n k v
t
tensorTrans (Int
i, Int
j) (Tensor TMap k (Tensor n k v)
m) = TMap k (Tensor n k v) -> Tensor (n + 1) k v
forall k (n :: Nat) v. TMap k (Tensor n k v) -> Tensor (n + 1) k v
Tensor (TMap k (Tensor n k v) -> Tensor (n + 1) k v)
-> TMap k (Tensor n k v) -> Tensor (n + 1) k v
forall a b. (a -> b) -> a -> b
$ (Tensor n k v -> Tensor n k v)
-> TMap k (Tensor n k v) -> TMap k (Tensor n k v)
forall v v' k. (v -> v') -> TMap k v -> TMap k v'
mapTMap ((Int, Int) -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
tensorTrans (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1, Int
jInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1)) TMap k (Tensor n k v)
m
tensorTrans (Int, Int)
_ Tensor n k v
ZeroTensor = Tensor n k v
forall (n :: Nat) k v. Tensor n k v
ZeroTensor
tensorTrans (Int, Int)
_ (Scalar v
_) = String -> Tensor n k v
forall a. HasCallStack => String -> a
error String
"attempt to transpose using a non-existing index"

-- | > tensorTrans1 = tensorTrans
tensorTrans1 :: (TIndex k1, TAdd v) => (Int,Int) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
tensorTrans1 :: (Int, Int) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
tensorTrans1 = (Int, Int) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
tensorTrans

-- | > tensorTrans2 mapTo1 . tensorTrans
tensorTrans2 :: (TIndex k1, TAdd v) => (Int,Int) -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
tensorTrans2 :: (Int, Int) -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
tensorTrans2 = (Tensor n2 k1 v -> Tensor n2 k1 v)
-> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 ((Tensor n2 k1 v -> Tensor n2 k1 v)
 -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v)
-> ((Int, Int) -> Tensor n2 k1 v -> Tensor n2 k1 v)
-> (Int, Int)
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n2 k1 v -> Tensor n2 k1 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
tensorTrans

-- | > tensorTrans3 = mapTo2 . tensorTrans
tensorTrans3 :: (TIndex k1, TIndex k2, TAdd v) => (Int,Int) -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
tensorTrans3 :: (Int, Int)
-> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
tensorTrans3 = (Tensor n3 k2 v -> Tensor n3 k2 v)
-> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 ((Tensor n3 k2 v -> Tensor n3 k2 v)
 -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v)
-> ((Int, Int) -> Tensor n3 k2 v -> Tensor n3 k2 v)
-> (Int, Int)
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n3 k2 v -> Tensor n3 k2 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
tensorTrans

-- | > tensorTrans4 = mapTo3 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
tensorTrans4 :: (Int, Int)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
tensorTrans4 = (Tensor n4 k2 v -> Tensor n4 k2 v)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 ((Tensor n4 k2 v -> Tensor n4 k2 v)
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v)
-> ((Int, Int) -> Tensor n4 k2 v -> Tensor n4 k2 v)
-> (Int, Int)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n4 k2 v -> Tensor n4 k2 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
tensorTrans

-- | > tensorTrans5 = mapTo4 . 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
tensorTrans5 :: (Int, Int)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
tensorTrans5 = (Tensor n5 k3 v -> Tensor n5 k3 v)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 ((Tensor n5 k3 v -> Tensor n5 k3 v)
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v)
-> ((Int, Int) -> Tensor n5 k3 v -> Tensor n5 k3 v)
-> (Int, Int)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n5 k3 v -> Tensor n5 k3 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
tensorTrans

-- | > tensorTrans6 = mapTo5 . 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
tensorTrans6 :: (Int, Int)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
tensorTrans6 = (Tensor n6 k3 v -> Tensor n6 k3 v)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 ((Tensor n6 k3 v -> Tensor n6 k3 v)
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> ((Int, Int) -> Tensor n6 k3 v -> Tensor n6 k3 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n6 k3 v -> Tensor n6 k3 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
tensorTrans

-- | > tensorTrans7 = mapTo6 . 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
tensorTrans7 :: (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
tensorTrans7 = (Tensor n7 k4 v -> Tensor n7 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 ((Tensor n7 k4 v -> Tensor n7 k4 v)
 -> 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)
-> ((Int, Int) -> Tensor n7 k4 v -> Tensor n7 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n7 k4 v -> Tensor n7 k4 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
tensorTrans

-- | > tensorTrans8 = mapTo7 . 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
tensorTrans8 :: (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
tensorTrans8 = (Tensor n8 k4 v -> Tensor n8 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4.
(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
mapTo7 ((Tensor n8 k4 v -> Tensor n8 k4 v)
 -> 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)
-> ((Int, Int) -> Tensor n8 k4 v -> Tensor n8 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n8 k4 v -> Tensor n8 k4 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
tensorTrans


-- | Swap, i.e. transpose two index blocks in a given @'Tensor'@. The two index blocks must be disjoint.
tensorBlockTrans :: (TIndex k, TAdd v) => ([Int],[Int]) -> Tensor n k v -> Tensor n k v
tensorBlockTrans :: ([Int], [Int]) -> Tensor n k v -> Tensor n k v
tensorBlockTrans ([Int]
l1,[Int]
l2) Tensor n k v
t = ((Int, Int) -> Tensor n k v -> Tensor n k v)
-> Tensor n k v -> [(Int, Int)] -> Tensor n k v
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (Int, Int) -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
tensorTrans Tensor n k v
t [(Int, Int)]
indList
        where
            indList :: [(Int, Int)]
indList = if [Int] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([Int] -> Bool) -> [Int] -> Bool
forall a b. (a -> b) -> a -> b
$ [Int] -> [Int] -> [Int]
forall a. Eq a => [a] -> [a] -> [a]
intersect [Int]
l1 [Int]
l2 then [Int] -> [Int] -> [(Int, Int)]
forall a b. [a] -> [b] -> [(a, b)]
zip [Int]
l1 [Int]
l2 else String -> [(Int, Int)]
forall a. HasCallStack => String -> a
error String
"at least one index in the list occurs several times"

-- | > tensorBlockTrans1 = tensorBlockTrans
tensorBlockTrans1 :: (TIndex k1, TAdd v) => ([Int],[Int]) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
tensorBlockTrans1 :: ([Int], [Int]) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
tensorBlockTrans1 = ([Int], [Int]) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
tensorBlockTrans

-- | > tensorBlockTrans2 = mapTo1 tensorBlockTrans
tensorBlockTrans2 :: (TIndex k1, TAdd v) => ([Int],[Int]) -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
tensorBlockTrans2 :: ([Int], [Int]) -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
tensorBlockTrans2 = (Tensor n2 k1 v -> Tensor n2 k1 v)
-> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 ((Tensor n2 k1 v -> Tensor n2 k1 v)
 -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v)
-> (([Int], [Int]) -> Tensor n2 k1 v -> Tensor n2 k1 v)
-> ([Int], [Int])
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n2 k1 v -> Tensor n2 k1 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
tensorBlockTrans

-- | > tensorBlockTrans3 = mapTo2 . tensorBlockTrans
tensorBlockTrans3 :: (TIndex k1, TIndex k2, TAdd v) => ([Int],[Int]) -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
tensorBlockTrans3 :: ([Int], [Int])
-> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
tensorBlockTrans3 = (Tensor n3 k2 v -> Tensor n3 k2 v)
-> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 ((Tensor n3 k2 v -> Tensor n3 k2 v)
 -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v)
-> (([Int], [Int]) -> Tensor n3 k2 v -> Tensor n3 k2 v)
-> ([Int], [Int])
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n3 k2 v -> Tensor n3 k2 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
tensorBlockTrans

-- | > tensorBlockTrans4 = mapTo3 . 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
tensorBlockTrans4 :: ([Int], [Int])
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
tensorBlockTrans4 = (Tensor n4 k2 v -> Tensor n4 k2 v)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 ((Tensor n4 k2 v -> Tensor n4 k2 v)
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v)
-> (([Int], [Int]) -> Tensor n4 k2 v -> Tensor n4 k2 v)
-> ([Int], [Int])
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n4 k2 v -> Tensor n4 k2 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
tensorBlockTrans

-- | > tensorBlockTrans5 = mapTo4 . 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
tensorBlockTrans5 :: ([Int], [Int])
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
tensorBlockTrans5 = (Tensor n5 k3 v -> Tensor n5 k3 v)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 ((Tensor n5 k3 v -> Tensor n5 k3 v)
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v)
-> (([Int], [Int]) -> Tensor n5 k3 v -> Tensor n5 k3 v)
-> ([Int], [Int])
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n5 k3 v -> Tensor n5 k3 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
tensorBlockTrans

-- | > tensorBlockTrans6 = mapTo5 . 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
tensorBlockTrans6 :: ([Int], [Int])
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
tensorBlockTrans6 = (Tensor n6 k3 v -> Tensor n6 k3 v)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 ((Tensor n6 k3 v -> Tensor n6 k3 v)
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> (([Int], [Int]) -> Tensor n6 k3 v -> Tensor n6 k3 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n6 k3 v -> Tensor n6 k3 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
tensorBlockTrans

-- | > tensorBlockTrans7 = mapTo6 . 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
tensorBlockTrans7 :: ([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
tensorBlockTrans7 = (Tensor n7 k4 v -> Tensor n7 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 ((Tensor n7 k4 v -> Tensor n7 k4 v)
 -> 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)
-> (([Int], [Int]) -> Tensor n7 k4 v -> Tensor n7 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n7 k4 v -> Tensor n7 k4 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
tensorBlockTrans

-- | > tensorBlockTrans8 = mapTo7 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
tensorBlockTrans8 :: ([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
tensorBlockTrans8 = (Tensor n8 k4 v -> Tensor n8 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4.
(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
mapTo7 ((Tensor n8 k4 v -> Tensor n8 k4 v)
 -> 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)
-> (([Int], [Int]) -> Tensor n8 k4 v -> Tensor n8 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n8 k4 v -> Tensor n8 k4 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
tensorBlockTrans

--resort an AbsTens

-- | 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)
resortTens :: (KnownNat n, TIndex k, TAdd v) => [Int] -> Tensor n k v -> Tensor n k v
resortTens :: [Int] -> Tensor n k v -> Tensor n k v
resortTens [Int]
perm Tensor n k v
t = [(IndList n k, v)] -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[(IndList n k, v)] -> Tensor n k v
fromListT ([(IndList n k, v)] -> Tensor n k v)
-> [(IndList n k, v)] -> Tensor n k v
forall a b. (a -> b) -> a -> b
$ ((IndList n k, v) -> (IndList n k, v))
-> [(IndList n k, v)] -> [(IndList n k, v)]
forall a b. (a -> b) -> [a] -> [b]
map (\(IndList n k
x,v
y) -> ([Int] -> IndList n k -> IndList n k
forall (n :: Nat) a.
(KnownNat n, Ord a) =>
[Int] -> IndList n a -> IndList n a
resortInd [Int]
perm IndList n k
x, v
y)) ([(IndList n k, v)] -> [(IndList n k, v)])
-> [(IndList n k, v)] -> [(IndList n k, v)]
forall a b. (a -> b) -> a -> b
$ Tensor n k v -> [(IndList n k, v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n k v
t

-- | > resortTens1 = resortTens
resortTens1 :: (KnownNat n1, TIndex k1, TAdd v) => [Int] -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
resortTens1 :: [Int] -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
resortTens1 = [Int] -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
forall (n :: Nat) k v.
(KnownNat n, TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
resortTens

-- | > resortTens2 = mapTo1 . resortTens
resortTens2 :: (KnownNat n2, TIndex k1, TAdd v) => [Int] -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
resortTens2 :: [Int] -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
resortTens2 = (Tensor n2 k1 v -> Tensor n2 k1 v)
-> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 ((Tensor n2 k1 v -> Tensor n2 k1 v)
 -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v)
-> ([Int] -> Tensor n2 k1 v -> Tensor n2 k1 v)
-> [Int]
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n2 k1 v -> Tensor n2 k1 v
forall (n :: Nat) k v.
(KnownNat n, TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
resortTens

-- | > resortTens3 = mapTo2 . 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
resortTens3 :: [Int] -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
resortTens3 = (Tensor n3 k2 v -> Tensor n3 k2 v)
-> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 ((Tensor n3 k2 v -> Tensor n3 k2 v)
 -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v)
-> ([Int] -> Tensor n3 k2 v -> Tensor n3 k2 v)
-> [Int]
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n3 k2 v -> Tensor n3 k2 v
forall (n :: Nat) k v.
(KnownNat n, TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
resortTens

-- | > resortTens4 = mapTo3 . 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
resortTens4 :: [Int]
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
resortTens4 = (Tensor n4 k2 v -> Tensor n4 k2 v)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 ((Tensor n4 k2 v -> Tensor n4 k2 v)
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v)
-> ([Int] -> Tensor n4 k2 v -> Tensor n4 k2 v)
-> [Int]
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n4 k2 v -> Tensor n4 k2 v
forall (n :: Nat) k v.
(KnownNat n, TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
resortTens

-- | > resortTens5 = mapTo4 . 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
resortTens5 :: [Int]
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
resortTens5 = (Tensor n5 k3 v -> Tensor n5 k3 v)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 ((Tensor n5 k3 v -> Tensor n5 k3 v)
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v)
-> ([Int] -> Tensor n5 k3 v -> Tensor n5 k3 v)
-> [Int]
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n5 k3 v -> Tensor n5 k3 v
forall (n :: Nat) k v.
(KnownNat n, TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
resortTens

-- | > resortTens6 = mapTo5 . 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
resortTens6 :: [Int]
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
resortTens6 = (Tensor n6 k3 v -> Tensor n6 k3 v)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 ((Tensor n6 k3 v -> Tensor n6 k3 v)
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> ([Int] -> Tensor n6 k3 v -> Tensor n6 k3 v)
-> [Int]
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n6 k3 v -> Tensor n6 k3 v
forall (n :: Nat) k v.
(KnownNat n, TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
resortTens

-- | > resortTens7 = mapTo6 . 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
resortTens7 :: [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
resortTens7 = (Tensor n7 k4 v -> Tensor n7 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 ((Tensor n7 k4 v -> Tensor n7 k4 v)
 -> 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)
-> ([Int] -> Tensor n7 k4 v -> Tensor n7 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n7 k4 v -> Tensor n7 k4 v
forall (n :: Nat) k v.
(KnownNat n, TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
resortTens

-- | > resortTens8 = mapTo7 . 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
resortTens8 :: [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
resortTens8 = (Tensor n8 k4 v -> Tensor n8 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4.
(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
mapTo7 ((Tensor n8 k4 v -> Tensor n8 k4 v)
 -> 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)
-> ([Int] -> Tensor n8 k4 v -> Tensor n8 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n8 k4 v -> Tensor n8 k4 v
forall (n :: Nat) k v.
(KnownNat n, TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
resortTens

--evaluation of a tensor for a specific index value returning the appropriate sub tensor

-- | 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.
evalTens :: (KnownNat n, 1<=n, TIndex k, TAdd v) => Int -> k -> Tensor n k v -> Tensor (n-1) k v
evalTens :: Int -> k -> Tensor n k v -> Tensor (n - 1) k v
evalTens Int
ind k
indVal (Tensor TMap k (Tensor n k v)
m)
            | Int
ind Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
size Int -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1 Bool -> Bool -> Bool
|| Int
ind Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0 = String -> Tensor (n - 1) k v
forall a. HasCallStack => String -> a
error String
"wrong index to evaluate"
            | Int
ind Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 = Tensor n k v -> Maybe (Tensor n k v) -> Tensor n k v
forall a. a -> Maybe a -> a
fromMaybe Tensor n k v
forall (n :: Nat) k v. Tensor n k v
ZeroTensor (Maybe (Tensor n k v) -> Tensor n k v)
-> Maybe (Tensor n k v) -> Tensor n k v
forall a b. (a -> b) -> a -> b
$ k -> TMap k (Tensor n k v) -> Maybe (Tensor n k v)
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup k
indVal TMap k (Tensor n k v)
m
            | Bool
otherwise = Tensor n k v -> Maybe (Tensor n k v) -> Tensor n k v
forall a. a -> Maybe a -> a
fromMaybe Tensor n k v
forall (n :: Nat) k v. Tensor n k v
ZeroTensor (Maybe (Tensor n k v) -> Tensor n k v)
-> Maybe (Tensor n k v) -> Tensor n k v
forall a b. (a -> b) -> a -> b
$ k -> TMap k (Tensor n k v) -> Maybe (Tensor n k v)
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup k
indVal (Tensor n k v -> TMap k (Tensor (n - 1) k v)
forall (n :: Nat) k v.
(1 <= n) =>
Tensor n k v -> TMap k (Tensor (n - 1) k v)
getTensorMap Tensor n k v
newTens)
            where
                size :: Int
size = [Int] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length ([Int] -> Int) -> [Int] -> Int
forall a b. (a -> b) -> a -> b
$ ([Int], v) -> [Int]
forall a b. (a, b) -> a
fst (([Int], v) -> [Int]) -> ([Int], v) -> [Int]
forall a b. (a -> b) -> a -> b
$ [([Int], v)] -> ([Int], v)
forall a. [a] -> a
head ([([Int], v)] -> ([Int], v)) -> [([Int], v)] -> ([Int], v)
forall a b. (a -> b) -> a -> b
$ Tensor n k v -> [([Int], v)]
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> [([Int], v)]
toListT' (TMap k (Tensor n k v) -> Tensor (n + 1) k v
forall k (n :: Nat) v. TMap k (Tensor n k v) -> Tensor (n + 1) k v
Tensor TMap k (Tensor n k v)
m)
                l :: [Int]
l = [Int
1..Int
ind] [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++ Int
0 Int -> [Int] -> [Int]
forall a. a -> [a] -> [a]
: [Int
indInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1..Int
size Int -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1]
                newTens :: Tensor n k v
newTens = [Int] -> Tensor n k v -> Tensor n k v
forall (n :: Nat) k v.
(KnownNat n, TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
resortTens [Int]
l (TMap k (Tensor n k v) -> Tensor (n + 1) k v
forall k (n :: Nat) v. TMap k (Tensor n k v) -> Tensor (n + 1) k v
Tensor TMap k (Tensor n k v)
m)
evalTens Int
_ k
_ Tensor n k v
ZeroTensor = Tensor (n - 1) k v
forall (n :: Nat) k v. Tensor n k v
ZeroTensor

-- | > evalTens1 = evalTens
evalTens1 :: (KnownNat n1, TIndex k1, TAdd v) => Int -> k1 -> AbsTensor1 (n1+1) k1 v -> AbsTensor1 n1 k1 v
evalTens1 :: Int -> k1 -> AbsTensor1 (n1 + 1) k1 v -> AbsTensor1 n1 k1 v
evalTens1 = Int -> k1 -> AbsTensor1 (n1 + 1) k1 v -> AbsTensor1 n1 k1 v
forall (n :: Nat) k v.
(KnownNat n, 1 <= n, TIndex k, TAdd v) =>
Int -> k -> Tensor n k v -> Tensor (n - 1) k v
evalTens

-- | > evalTens2 ind indVal = mapTo1 (evalTens ind indVal)
evalTens2 :: (KnownNat n2, TIndex k1, TAdd v) => Int -> k1 -> AbsTensor2 n1 (n2+1) k1 v  -> AbsTensor2 n1 n2 k1 v
evalTens2 :: Int -> k1 -> AbsTensor2 n1 (n2 + 1) k1 v -> AbsTensor2 n1 n2 k1 v
evalTens2 Int
ind k1
indVal = (Tensor (n2 + 1) k1 v -> Tensor n2 k1 v)
-> AbsTensor2 n1 (n2 + 1) k1 v -> AbsTensor2 n1 n2 k1 v
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 (Int -> k1 -> Tensor (n2 + 1) k1 v -> Tensor ((n2 + 1) - 1) k1 v
forall (n :: Nat) k v.
(KnownNat n, 1 <= n, TIndex k, TAdd v) =>
Int -> k -> Tensor n k v -> Tensor (n - 1) k v
evalTens Int
ind k1
indVal)

-- | > evalTens3 ind indVal = mapTo2 (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
evalTens3 :: Int
-> k2
-> AbsTensor3 n1 n2 (n3 + 1) k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 v
evalTens3 Int
ind k2
indVal = (Tensor (n3 + 1) k2 v -> Tensor n3 k2 v)
-> AbsTensor3 n1 n2 (n3 + 1) k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 (Int -> k2 -> Tensor (n3 + 1) k2 v -> Tensor ((n3 + 1) - 1) k2 v
forall (n :: Nat) k v.
(KnownNat n, 1 <= n, TIndex k, TAdd v) =>
Int -> k -> Tensor n k v -> Tensor (n - 1) k v
evalTens Int
ind k2
indVal)

-- | > evalTens4 ind indVal = mapTo3 (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
evalTens4 :: Int
-> k2
-> AbsTensor4 n1 n2 n3 (n4 + 1) k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
evalTens4 Int
ind k2
indVal = (Tensor (n4 + 1) k2 v -> Tensor n4 k2 v)
-> AbsTensor4 n1 n2 n3 (n4 + 1) k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 (Int -> k2 -> Tensor (n4 + 1) k2 v -> Tensor ((n4 + 1) - 1) k2 v
forall (n :: Nat) k v.
(KnownNat n, 1 <= n, TIndex k, TAdd v) =>
Int -> k -> Tensor n k v -> Tensor (n - 1) k v
evalTens Int
ind k2
indVal)

-- | > evalTens5 ind indVal = mapTo4 (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
evalTens5 :: Int
-> k3
-> AbsTensor5 n1 n2 n3 n4 (n5 + 1) k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
evalTens5 Int
ind k3
indVal = (Tensor (n5 + 1) k3 v -> Tensor n5 k3 v)
-> AbsTensor5 n1 n2 n3 n4 (n5 + 1) k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 (Int -> k3 -> Tensor (n5 + 1) k3 v -> Tensor ((n5 + 1) - 1) k3 v
forall (n :: Nat) k v.
(KnownNat n, 1 <= n, TIndex k, TAdd v) =>
Int -> k -> Tensor n k v -> Tensor (n - 1) k v
evalTens Int
ind k3
indVal)

-- | > evalTens6 ind indVal = mapTo5 (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
evalTens6 :: 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
evalTens6 Int
ind k3
indVal = (Tensor (n6 + 1) k3 v -> Tensor n6 k3 v)
-> AbsTensor6 n1 n2 n3 n4 n5 (n6 + 1) k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 (Int -> k3 -> Tensor (n6 + 1) k3 v -> Tensor ((n6 + 1) - 1) k3 v
forall (n :: Nat) k v.
(KnownNat n, 1 <= n, TIndex k, TAdd v) =>
Int -> k -> Tensor n k v -> Tensor (n - 1) k v
evalTens Int
ind k3
indVal)

-- | > evalTens7 ind indVal = mapTo6 (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
evalTens7 :: 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
evalTens7 Int
ind k4
indVal = (Tensor (n7 + 1) k4 v -> Tensor n7 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 (Int -> k4 -> Tensor (n7 + 1) k4 v -> Tensor ((n7 + 1) - 1) k4 v
forall (n :: Nat) k v.
(KnownNat n, 1 <= n, TIndex k, TAdd v) =>
Int -> k -> Tensor n k v -> Tensor (n - 1) k v
evalTens Int
ind k4
indVal)

-- | > evalTens8 ind indVal = mapTo7 (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
evalTens8 :: 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
evalTens8 Int
ind k4
indVal = (Tensor (n8 + 1) k4 v -> Tensor n8 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4.
(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
mapTo7 (Int -> k4 -> Tensor (n8 + 1) k4 v -> Tensor ((n8 + 1) - 1) k4 v
forall (n :: Nat) k v.
(KnownNat n, 1 <= n, TIndex k, TAdd v) =>
Int -> k -> Tensor n k v -> Tensor (n - 1) k v
evalTens Int
ind k4
indVal)

--symmetrizer functions

-- | 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.
symTens :: (TIndex k, TAdd v) => (Int,Int) -> Tensor n k v -> Tensor n k v
symTens :: (Int, Int) -> Tensor n k v -> Tensor n k v
symTens (Int, Int)
inds Tensor n k v
t = Tensor n k v
t Tensor n k v -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
&+ (Int, Int) -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
tensorTrans (Int, Int)
inds Tensor n k v
t

-- | > symATens1 = symTens
symATens1 :: (TIndex k1, TAdd v) =>
             (Int,Int) ->
             AbsTensor1 n1 k1 v ->
             AbsTensor1 n1 k1 v
symATens1 :: (Int, Int) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
symATens1 = (Int, Int) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
symTens

-- | > symATens2 = mapTo1 . symTens
symATens2 :: (TIndex k1, TAdd v) =>
             (Int,Int) ->
             AbsTensor2 n1 n2 k1 v ->
             AbsTensor2 n1 n2 k1 v
symATens2 :: (Int, Int) -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
symATens2 = (Tensor n2 k1 v -> Tensor n2 k1 v)
-> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 ((Tensor n2 k1 v -> Tensor n2 k1 v)
 -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v)
-> ((Int, Int) -> Tensor n2 k1 v -> Tensor n2 k1 v)
-> (Int, Int)
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n2 k1 v -> Tensor n2 k1 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
symTens

-- | > symATens3 = mapTo2 . symTens
symATens3 :: (TIndex k1, TIndex k2, TAdd v) =>
             (Int,Int) ->
             AbsTensor3 n1 n2 n3 k1 k2 v ->
             AbsTensor3 n1 n2 n3 k1 k2 v
symATens3 :: (Int, Int)
-> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
symATens3 = (Tensor n3 k2 v -> Tensor n3 k2 v)
-> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 ((Tensor n3 k2 v -> Tensor n3 k2 v)
 -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v)
-> ((Int, Int) -> Tensor n3 k2 v -> Tensor n3 k2 v)
-> (Int, Int)
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n3 k2 v -> Tensor n3 k2 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
symTens

-- | > symATens4 = mapTo3 . 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
symATens4 :: (Int, Int)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
symATens4 = (Tensor n4 k2 v -> Tensor n4 k2 v)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 ((Tensor n4 k2 v -> Tensor n4 k2 v)
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v)
-> ((Int, Int) -> Tensor n4 k2 v -> Tensor n4 k2 v)
-> (Int, Int)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n4 k2 v -> Tensor n4 k2 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
symTens

-- | > symATens5 = mapTo4 . 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
symATens5 :: (Int, Int)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
symATens5 = (Tensor n5 k3 v -> Tensor n5 k3 v)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 ((Tensor n5 k3 v -> Tensor n5 k3 v)
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v)
-> ((Int, Int) -> Tensor n5 k3 v -> Tensor n5 k3 v)
-> (Int, Int)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n5 k3 v -> Tensor n5 k3 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
symTens

-- | > symATens6 = mapTo5 . 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
symATens6 :: (Int, Int)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
symATens6 = (Tensor n6 k3 v -> Tensor n6 k3 v)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 ((Tensor n6 k3 v -> Tensor n6 k3 v)
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> ((Int, Int) -> Tensor n6 k3 v -> Tensor n6 k3 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n6 k3 v -> Tensor n6 k3 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
symTens

-- | > symATens7 = mapTo6 . 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
symATens7 :: (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
symATens7 = (Tensor n7 k4 v -> Tensor n7 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 ((Tensor n7 k4 v -> Tensor n7 k4 v)
 -> 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)
-> ((Int, Int) -> Tensor n7 k4 v -> Tensor n7 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n7 k4 v -> Tensor n7 k4 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
symTens

-- | > symATens8 = mapTo7 . 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
symATens8 :: (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
symATens8 = (Tensor n8 k4 v -> Tensor n8 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4.
(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
mapTo7 ((Tensor n8 k4 v -> Tensor n8 k4 v)
 -> 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)
-> ((Int, Int) -> Tensor n8 k4 v -> Tensor n8 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n8 k4 v -> Tensor n8 k4 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
symTens

--with factor

-- | 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
symTensFac :: (TIndex k, TAdd v, Prod (SField Rational) v) => (Int,Int) -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
symTensFac :: (Int, Int)
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
symTensFac (Int, Int)
inds Tensor n k v
t = Rational -> SField Rational
forall a. a -> SField a
SField (Rational
1Rational -> Rational -> Rational
forall a. Fractional a => a -> a -> a
/Rational
2 :: Rational) SField Rational
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
forall k s v (n :: Nat).
(TIndex k, Prod s v) =>
s -> Tensor n k v -> Tensor n k (TProd s v)
&. (Int, Int) -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
symTens (Int, Int)
inds Tensor n k v
t

-- | > symATensFac1 = symTensFac
symATensFac1 :: (TIndex k1, TAdd v, Prod (SField Rational) v) =>
                (Int,Int) ->
                AbsTensor1 n1 k1 v ->
                AbsTensor1 n1 k1 (TProd (SField Rational) v)
symATensFac1 :: (Int, Int)
-> AbsTensor1 n1 k1 v
-> AbsTensor1 n1 k1 (TProd (SField Rational) v)
symATensFac1 = (Int, Int)
-> AbsTensor1 n1 k1 v
-> AbsTensor1 n1 k1 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
(Int, Int)
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
symTensFac

-- | > symATensFac2 = mapTo1 . 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)
symATensFac2 :: (Int, Int)
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
symATensFac2 = (Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 ((Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
 -> AbsTensor2 n1 n2 k1 v
 -> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v))
-> ((Int, Int)
    -> Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
-> (Int, Int)
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int)
-> Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
(Int, Int)
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
symTensFac

-- | > symATensFac3 = mapTo2 . 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)
symATensFac3 :: (Int, Int)
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
symATensFac3 = (Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 ((Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
 -> AbsTensor3 n1 n2 n3 k1 k2 v
 -> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v))
-> ((Int, Int)
    -> Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
-> (Int, Int)
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int)
-> Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
(Int, Int)
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
symTensFac

-- | > symATensFac4 = mapTo3 . 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)
symATensFac4 :: (Int, Int)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
symATensFac4 = (Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 ((Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v))
-> ((Int, Int)
    -> Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
-> (Int, Int)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int)
-> Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
(Int, Int)
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
symTensFac

-- | > symATensFac5 = mapTo4 . 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)
symATensFac5 :: (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)
symATensFac5 = (Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v))
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 ((Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v))
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v))
-> ((Int, Int)
    -> Tensor n5 k3 v -> Tensor n5 k3 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int)
-> Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
(Int, Int)
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
symTensFac

-- | > symATensFac6 = mapTo5 . 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)
symATensFac6 :: (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)
symATensFac6 = (Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 ((Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v))
 -> 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))
-> ((Int, Int)
    -> Tensor n6 k3 v -> Tensor n6 k3 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int)
-> Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
(Int, Int)
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
symTensFac

-- | > symATensFac7 = mapTo6 . 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)
symATensFac7 :: (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)
symATensFac7 = (Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 ((Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v))
 -> 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))
-> ((Int, Int)
    -> Tensor n7 k4 v -> Tensor n7 k4 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int)
-> Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
(Int, Int)
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
symTensFac

-- | > symATensFac8 = mapTo7 . 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)
symATensFac8 :: (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)
symATensFac8 = (Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4.
(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
mapTo7 ((Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v))
 -> 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))
-> ((Int, Int)
    -> Tensor n8 k4 v -> Tensor n8 k4 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int)
-> Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
(Int, Int)
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
symTensFac

--anti-symmetrization

-- | 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.
aSymTens :: (TIndex k, TAdd v) => (Int,Int) -> Tensor n k v -> Tensor n k v
aSymTens :: (Int, Int) -> Tensor n k v -> Tensor n k v
aSymTens (Int, Int)
inds Tensor n k v
t = Tensor n k v
t Tensor n k v -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
&- (Int, Int) -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
tensorTrans (Int, Int)
inds Tensor n k v
t

-- | > aSymATens1 = aSymTens
aSymATens1 :: (TIndex k1, TAdd v) =>
              (Int,Int) ->
              AbsTensor1 n1 k1 v ->
              AbsTensor1 n1 k1 v
aSymATens1 :: (Int, Int) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
aSymATens1 = (Int, Int) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
aSymTens

-- | > aSymATens2 = mapTo1 . aSymTens
aSymATens2 :: (TIndex k1, TAdd v) =>
              (Int,Int) ->
              AbsTensor2 n1 n2 k1 v ->
              AbsTensor2 n1 n2 k1 v
aSymATens2 :: (Int, Int) -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
aSymATens2 = (Tensor n2 k1 v -> Tensor n2 k1 v)
-> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 ((Tensor n2 k1 v -> Tensor n2 k1 v)
 -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v)
-> ((Int, Int) -> Tensor n2 k1 v -> Tensor n2 k1 v)
-> (Int, Int)
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n2 k1 v -> Tensor n2 k1 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
aSymTens

-- | > aSymATens3 = mapTo2 . aSymTens
aSymATens3 :: (TIndex k1, TIndex k2, TAdd v) =>
              (Int,Int) ->
              AbsTensor3 n1 n2 n3 k1 k2 v ->
              AbsTensor3 n1 n2 n3 k1 k2 v
aSymATens3 :: (Int, Int)
-> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
aSymATens3 = (Tensor n3 k2 v -> Tensor n3 k2 v)
-> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 ((Tensor n3 k2 v -> Tensor n3 k2 v)
 -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v)
-> ((Int, Int) -> Tensor n3 k2 v -> Tensor n3 k2 v)
-> (Int, Int)
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n3 k2 v -> Tensor n3 k2 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
aSymTens

-- | > aSymATens4 = mapTo3 . 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
aSymATens4 :: (Int, Int)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
aSymATens4 = (Tensor n4 k2 v -> Tensor n4 k2 v)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 ((Tensor n4 k2 v -> Tensor n4 k2 v)
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v)
-> ((Int, Int) -> Tensor n4 k2 v -> Tensor n4 k2 v)
-> (Int, Int)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n4 k2 v -> Tensor n4 k2 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
aSymTens

-- | > aSymATens5 = mapTo4 . 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
aSymATens5 :: (Int, Int)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
aSymATens5 = (Tensor n5 k3 v -> Tensor n5 k3 v)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 ((Tensor n5 k3 v -> Tensor n5 k3 v)
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v)
-> ((Int, Int) -> Tensor n5 k3 v -> Tensor n5 k3 v)
-> (Int, Int)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n5 k3 v -> Tensor n5 k3 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
aSymTens

-- | > aSymATens6 = mapTo5 . 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
aSymATens6 :: (Int, Int)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
aSymATens6 = (Tensor n6 k3 v -> Tensor n6 k3 v)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 ((Tensor n6 k3 v -> Tensor n6 k3 v)
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> ((Int, Int) -> Tensor n6 k3 v -> Tensor n6 k3 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n6 k3 v -> Tensor n6 k3 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
aSymTens

-- | > aSymATens7 = mapTo6 . 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
aSymATens7 :: (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
aSymATens7 = (Tensor n7 k4 v -> Tensor n7 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 ((Tensor n7 k4 v -> Tensor n7 k4 v)
 -> 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)
-> ((Int, Int) -> Tensor n7 k4 v -> Tensor n7 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n7 k4 v -> Tensor n7 k4 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
aSymTens

-- | > aSymATens8 = mapTo7 . 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
aSymATens8 :: (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
aSymATens8 = (Tensor n8 k4 v -> Tensor n8 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4.
(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
mapTo7 ((Tensor n8 k4 v -> Tensor n8 k4 v)
 -> 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)
-> ((Int, Int) -> Tensor n8 k4 v -> Tensor n8 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor n8 k4 v -> Tensor n8 k4 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
aSymTens

--with factor

-- | 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
aSymTensFac :: (TIndex k, TAdd v, Prod (SField Rational) v) => (Int,Int) -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
aSymTensFac :: (Int, Int)
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
aSymTensFac (Int, Int)
inds Tensor n k v
t = Rational -> SField Rational
forall a. a -> SField a
SField (Rational
1Rational -> Rational -> Rational
forall a. Fractional a => a -> a -> a
/Rational
2 :: Rational) SField Rational
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
forall k s v (n :: Nat).
(TIndex k, Prod s v) =>
s -> Tensor n k v -> Tensor n k (TProd s v)
&. (Int, Int) -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
aSymTens (Int, Int)
inds Tensor n k v
t

-- | > aSymATensFac1 = aSymTensFac
aSymATensFac1 :: (TIndex k1, TAdd v, Prod (SField Rational) v) =>
                 (Int,Int) ->
                 AbsTensor1 n1 k1 v ->
                 AbsTensor1 n1 k1 (TProd (SField Rational) v)
aSymATensFac1 :: (Int, Int)
-> AbsTensor1 n1 k1 v
-> AbsTensor1 n1 k1 (TProd (SField Rational) v)
aSymATensFac1 = (Int, Int)
-> AbsTensor1 n1 k1 v
-> AbsTensor1 n1 k1 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
(Int, Int)
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
aSymTensFac

-- | > aSymATensFac2 = mapTo1 . 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)
aSymATensFac2 :: (Int, Int)
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
aSymATensFac2 = (Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 ((Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
 -> AbsTensor2 n1 n2 k1 v
 -> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v))
-> ((Int, Int)
    -> Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
-> (Int, Int)
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int)
-> Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
(Int, Int)
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
aSymTensFac

-- | > aSymATensFac3 = mapTo2 . 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)
aSymATensFac3 :: (Int, Int)
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
aSymATensFac3 = (Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 ((Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
 -> AbsTensor3 n1 n2 n3 k1 k2 v
 -> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v))
-> ((Int, Int)
    -> Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
-> (Int, Int)
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int)
-> Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
(Int, Int)
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
aSymTensFac

-- | > aSymATensFac4 = mapTo3 . 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)
aSymATensFac4 :: (Int, Int)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
aSymATensFac4 = (Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 ((Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v))
-> ((Int, Int)
    -> Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
-> (Int, Int)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int)
-> Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
(Int, Int)
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
aSymTensFac

-- | > aSymATensFac5 = mapTo4 . 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)
aSymATensFac5 :: (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)
aSymATensFac5 = (Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v))
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 ((Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v))
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v))
-> ((Int, Int)
    -> Tensor n5 k3 v -> Tensor n5 k3 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int)
-> Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
(Int, Int)
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
aSymTensFac

-- | > aSymATensFac6 = mapTo5 . 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)
aSymATensFac6 :: (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)
aSymATensFac6 = (Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 ((Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v))
 -> 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))
-> ((Int, Int)
    -> Tensor n6 k3 v -> Tensor n6 k3 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int)
-> Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
(Int, Int)
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
aSymTensFac

-- | > aSymATensFac7 = mapTo6 . 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)
aSymATensFac7 :: (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)
aSymATensFac7 = (Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 ((Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v))
 -> 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))
-> ((Int, Int)
    -> Tensor n7 k4 v -> Tensor n7 k4 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int)
-> Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
(Int, Int)
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
aSymTensFac

-- | > aSymATensFac8 = mapTo7 . 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)
aSymATensFac8 :: (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)
aSymATensFac8 = (Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4.
(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
mapTo7 ((Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v))
 -> 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))
-> ((Int, Int)
    -> Tensor n8 k4 v -> Tensor n8 k4 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int)
-> Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
(Int, Int)
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
aSymTensFac

--block symmetrization

-- | 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.
symBlockTens :: (TIndex k, TAdd v) => ([Int],[Int]) -> Tensor n k v -> Tensor n k v
symBlockTens :: ([Int], [Int]) -> Tensor n k v -> Tensor n k v
symBlockTens ([Int], [Int])
inds Tensor n k v
t = Tensor n k v
t Tensor n k v -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
&+ ([Int], [Int]) -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
tensorBlockTrans ([Int], [Int])
inds Tensor n k v
t

-- | > symBlockATens1 = symBlockTens
symBlockATens1 :: (TIndex k1, TAdd v) =>
                  ([Int],[Int]) ->
                  AbsTensor1 n1 k1 v ->
                  AbsTensor1 n1 k1 v
symBlockATens1 :: ([Int], [Int]) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
symBlockATens1 = ([Int], [Int]) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
symBlockTens

-- | > symBlockATens2 = mapTo1 . symBlockTens
symBlockATens2 :: (TIndex k1, TAdd v) =>
                  ([Int],[Int]) ->
                  AbsTensor2 n1 n2 k1 v ->
                  AbsTensor2 n1 n2 k1 v
symBlockATens2 :: ([Int], [Int]) -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
symBlockATens2 = (Tensor n2 k1 v -> Tensor n2 k1 v)
-> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 ((Tensor n2 k1 v -> Tensor n2 k1 v)
 -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v)
-> (([Int], [Int]) -> Tensor n2 k1 v -> Tensor n2 k1 v)
-> ([Int], [Int])
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n2 k1 v -> Tensor n2 k1 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
symBlockTens

-- | > symBlockATens3 = mapTo2 . symBlockTens
symBlockATens3 :: (TIndex k1, TIndex k2, TAdd v) =>
                  ([Int],[Int]) ->
                  AbsTensor3 n1 n2 n3 k1 k2 v ->
                  AbsTensor3 n1 n2 n3 k1 k2 v
symBlockATens3 :: ([Int], [Int])
-> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
symBlockATens3 = (Tensor n3 k2 v -> Tensor n3 k2 v)
-> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 ((Tensor n3 k2 v -> Tensor n3 k2 v)
 -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v)
-> (([Int], [Int]) -> Tensor n3 k2 v -> Tensor n3 k2 v)
-> ([Int], [Int])
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n3 k2 v -> Tensor n3 k2 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
symBlockTens

-- | > symBlockATens4 = mapTo3 . 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
symBlockATens4 :: ([Int], [Int])
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
symBlockATens4 = (Tensor n4 k2 v -> Tensor n4 k2 v)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 ((Tensor n4 k2 v -> Tensor n4 k2 v)
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v)
-> (([Int], [Int]) -> Tensor n4 k2 v -> Tensor n4 k2 v)
-> ([Int], [Int])
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n4 k2 v -> Tensor n4 k2 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
symBlockTens

-- | > symBlockATens5 = mapTo4 . 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
symBlockATens5 :: ([Int], [Int])
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
symBlockATens5 = (Tensor n5 k3 v -> Tensor n5 k3 v)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 ((Tensor n5 k3 v -> Tensor n5 k3 v)
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v)
-> (([Int], [Int]) -> Tensor n5 k3 v -> Tensor n5 k3 v)
-> ([Int], [Int])
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n5 k3 v -> Tensor n5 k3 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
symBlockTens

-- | > symBlockATens6 = mapTo5 . 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
symBlockATens6 :: ([Int], [Int])
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
symBlockATens6 = (Tensor n6 k3 v -> Tensor n6 k3 v)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 ((Tensor n6 k3 v -> Tensor n6 k3 v)
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> (([Int], [Int]) -> Tensor n6 k3 v -> Tensor n6 k3 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n6 k3 v -> Tensor n6 k3 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
symBlockTens

-- | > symBlockATens7 = mapTo6 . 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
symBlockATens7 :: ([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
symBlockATens7 = (Tensor n7 k4 v -> Tensor n7 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 ((Tensor n7 k4 v -> Tensor n7 k4 v)
 -> 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)
-> (([Int], [Int]) -> Tensor n7 k4 v -> Tensor n7 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n7 k4 v -> Tensor n7 k4 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
symBlockTens

-- | > symBlockATens8 = mapTo7 . 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
symBlockATens8 :: ([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
symBlockATens8 = (Tensor n8 k4 v -> Tensor n8 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4.
(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
mapTo7 ((Tensor n8 k4 v -> Tensor n8 k4 v)
 -> 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)
-> (([Int], [Int]) -> Tensor n8 k4 v -> Tensor n8 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n8 k4 v -> Tensor n8 k4 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
symBlockTens

--with factor

-- | 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
symBlockTensFac :: (TIndex k, TAdd v, Prod (SField Rational) v) => ([Int],[Int]) -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
symBlockTensFac :: ([Int], [Int])
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
symBlockTensFac ([Int], [Int])
inds Tensor n k v
t = Rational -> SField Rational
forall a. a -> SField a
SField (Rational
1Rational -> Rational -> Rational
forall a. Fractional a => a -> a -> a
/Rational
2 :: Rational) SField Rational
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
forall k s v (n :: Nat).
(TIndex k, Prod s v) =>
s -> Tensor n k v -> Tensor n k (TProd s v)
&. ([Int], [Int]) -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
symBlockTens ([Int], [Int])
inds Tensor n k v
t

-- | > symBlockATensFac1 = symBlockTensFac
symBlockATensFac1 :: (TIndex k1, TAdd v, Prod (SField Rational) v) =>
                     ([Int],[Int]) ->
                     AbsTensor1 n1 k1 v ->
                     AbsTensor1 n1 k1 (TProd (SField Rational) v)
symBlockATensFac1 :: ([Int], [Int])
-> AbsTensor1 n1 k1 v
-> AbsTensor1 n1 k1 (TProd (SField Rational) v)
symBlockATensFac1 = ([Int], [Int])
-> AbsTensor1 n1 k1 v
-> AbsTensor1 n1 k1 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
([Int], [Int])
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
symBlockTensFac

-- | > symBlockATensFac2 = mapTo1 . 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)
symBlockATensFac2 :: ([Int], [Int])
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
symBlockATensFac2 = (Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 ((Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
 -> AbsTensor2 n1 n2 k1 v
 -> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v))
-> (([Int], [Int])
    -> Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
-> ([Int], [Int])
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int])
-> Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
([Int], [Int])
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
symBlockTensFac

-- | > symBlockATensFac3 = mapTo2 . 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)
symBlockATensFac3 :: ([Int], [Int])
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
symBlockATensFac3 = (Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 ((Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
 -> AbsTensor3 n1 n2 n3 k1 k2 v
 -> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v))
-> (([Int], [Int])
    -> Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
-> ([Int], [Int])
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int])
-> Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
([Int], [Int])
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
symBlockTensFac

-- | > symBlockATensFac4 = mapTo3 . 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)
symBlockATensFac4 :: ([Int], [Int])
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
symBlockATensFac4 = (Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 ((Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v))
-> (([Int], [Int])
    -> Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
-> ([Int], [Int])
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int])
-> Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
([Int], [Int])
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
symBlockTensFac

-- | > symBlockATensFac5 = mapTo4 . 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)
symBlockATensFac5 :: ([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)
symBlockATensFac5 = (Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v))
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 ((Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v))
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v))
-> (([Int], [Int])
    -> Tensor n5 k3 v -> Tensor n5 k3 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int])
-> Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
([Int], [Int])
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
symBlockTensFac

-- | > symBlockATensFac6 = mapTo5 . 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)
symBlockATensFac6 :: ([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)
symBlockATensFac6 = (Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 ((Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v))
 -> 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))
-> (([Int], [Int])
    -> Tensor n6 k3 v -> Tensor n6 k3 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int])
-> Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
([Int], [Int])
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
symBlockTensFac

-- | > symBlockATensFac7 = mapTo6 . 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)
symBlockATensFac7 :: ([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)
symBlockATensFac7 = (Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 ((Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v))
 -> 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))
-> (([Int], [Int])
    -> Tensor n7 k4 v -> Tensor n7 k4 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int])
-> Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
([Int], [Int])
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
symBlockTensFac

-- | > symBlockATensFac8 = mapTo7 . 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)
symBlockATensFac8 :: ([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)
symBlockATensFac8 = (Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4.
(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
mapTo7 ((Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v))
 -> 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))
-> (([Int], [Int])
    -> Tensor n8 k4 v -> Tensor n8 k4 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int])
-> Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
([Int], [Int])
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
symBlockTensFac

--anti symmetrization

-- | 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.
aSymBlockTens :: (TIndex k, TAdd v) => ([Int],[Int]) -> Tensor n k v -> Tensor n k v
aSymBlockTens :: ([Int], [Int]) -> Tensor n k v -> Tensor n k v
aSymBlockTens ([Int], [Int])
inds Tensor n k v
t = Tensor n k v
t Tensor n k v -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
&- ([Int], [Int]) -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
tensorBlockTrans ([Int], [Int])
inds Tensor n k v
t

-- | > aSymBlockATens1 = aSymBlockTens
aSymBlockATens1 :: (TIndex k1, TAdd v) =>
                   ([Int],[Int]) ->
                   AbsTensor1 n1 k1 v ->
                   AbsTensor1 n1 k1 v
aSymBlockATens1 :: ([Int], [Int]) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
aSymBlockATens1 = ([Int], [Int]) -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
aSymBlockTens

-- | > aSymBlockATens2 = mapTo1 . aSymBlockTens
aSymBlockATens2 :: (TIndex k1, TAdd v) =>
                   ([Int],[Int]) ->
                   AbsTensor2 n1 n2 k1 v ->
                   AbsTensor2 n1 n2 k1 v
aSymBlockATens2 :: ([Int], [Int]) -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
aSymBlockATens2 = (Tensor n2 k1 v -> Tensor n2 k1 v)
-> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 ((Tensor n2 k1 v -> Tensor n2 k1 v)
 -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v)
-> (([Int], [Int]) -> Tensor n2 k1 v -> Tensor n2 k1 v)
-> ([Int], [Int])
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n2 k1 v -> Tensor n2 k1 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
aSymBlockTens

-- | > aSymBlockATens3 = mapTo2 . aSymBlockTens
aSymBlockATens3 :: (TIndex k1, TIndex k2, TAdd v) =>
                   ([Int],[Int]) ->
                   AbsTensor3 n1 n2 n3 k1 k2 v ->
                   AbsTensor3 n1 n2 n3 k1 k2 v
aSymBlockATens3 :: ([Int], [Int])
-> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
aSymBlockATens3 = (Tensor n3 k2 v -> Tensor n3 k2 v)
-> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 ((Tensor n3 k2 v -> Tensor n3 k2 v)
 -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v)
-> (([Int], [Int]) -> Tensor n3 k2 v -> Tensor n3 k2 v)
-> ([Int], [Int])
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n3 k2 v -> Tensor n3 k2 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
aSymBlockTens

-- | > aSymBlockATens4 = mapTo3 . 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
aSymBlockATens4 :: ([Int], [Int])
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
aSymBlockATens4 = (Tensor n4 k2 v -> Tensor n4 k2 v)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 ((Tensor n4 k2 v -> Tensor n4 k2 v)
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v)
-> (([Int], [Int]) -> Tensor n4 k2 v -> Tensor n4 k2 v)
-> ([Int], [Int])
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n4 k2 v -> Tensor n4 k2 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
aSymBlockTens

-- | > aSymBlockATens5 = mapTo4 . 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
aSymBlockATens5 :: ([Int], [Int])
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
aSymBlockATens5 = (Tensor n5 k3 v -> Tensor n5 k3 v)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 ((Tensor n5 k3 v -> Tensor n5 k3 v)
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v)
-> (([Int], [Int]) -> Tensor n5 k3 v -> Tensor n5 k3 v)
-> ([Int], [Int])
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n5 k3 v -> Tensor n5 k3 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
aSymBlockTens

-- | > aSymBlockATens6 = mapTo5 . 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
aSymBlockATens6 :: ([Int], [Int])
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
aSymBlockATens6 = (Tensor n6 k3 v -> Tensor n6 k3 v)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 ((Tensor n6 k3 v -> Tensor n6 k3 v)
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> (([Int], [Int]) -> Tensor n6 k3 v -> Tensor n6 k3 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n6 k3 v -> Tensor n6 k3 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
aSymBlockTens

-- | > aSymBlockATens7 = mapTo6 . 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
aSymBlockATens7 :: ([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
aSymBlockATens7 = (Tensor n7 k4 v -> Tensor n7 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 ((Tensor n7 k4 v -> Tensor n7 k4 v)
 -> 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)
-> (([Int], [Int]) -> Tensor n7 k4 v -> Tensor n7 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n7 k4 v -> Tensor n7 k4 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
aSymBlockTens

-- | > aSymBlockATens8 = mapTo7 . 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
aSymBlockATens8 :: ([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
aSymBlockATens8 = (Tensor n8 k4 v -> Tensor n8 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4.
(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
mapTo7 ((Tensor n8 k4 v -> Tensor n8 k4 v)
 -> 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)
-> (([Int], [Int]) -> Tensor n8 k4 v -> Tensor n8 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int]) -> Tensor n8 k4 v -> Tensor n8 k4 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
aSymBlockTens

--with factor

-- | 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
aSymBlockTensFac :: (TIndex k, TAdd v, Prod (SField Rational) v) => ([Int],[Int]) -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
aSymBlockTensFac :: ([Int], [Int])
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
aSymBlockTensFac ([Int], [Int])
inds Tensor n k v
t = Rational -> SField Rational
forall a. a -> SField a
SField (Rational
1Rational -> Rational -> Rational
forall a. Fractional a => a -> a -> a
/Rational
2 :: Rational) SField Rational
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
forall k s v (n :: Nat).
(TIndex k, Prod s v) =>
s -> Tensor n k v -> Tensor n k (TProd s v)
&. ([Int], [Int]) -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
aSymBlockTens ([Int], [Int])
inds Tensor n k v
t

-- | > aSymBlockATensFac1 = aSymBlockTensFac
aSymBlockATensFac1 :: (TIndex k1, TAdd v, Prod (SField Rational) v) =>
                      ([Int],[Int]) ->
                      AbsTensor1 n1 k1 v ->
                      AbsTensor1 n1 k1 (TProd (SField Rational) v)
aSymBlockATensFac1 :: ([Int], [Int])
-> AbsTensor1 n1 k1 v
-> AbsTensor1 n1 k1 (TProd (SField Rational) v)
aSymBlockATensFac1 = ([Int], [Int])
-> AbsTensor1 n1 k1 v
-> AbsTensor1 n1 k1 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
([Int], [Int])
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
aSymBlockTensFac

-- | > aSymBlockATensFac2 = mapTo1 . 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)
aSymBlockATensFac2 :: ([Int], [Int])
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
aSymBlockATensFac2 = (Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 ((Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
 -> AbsTensor2 n1 n2 k1 v
 -> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v))
-> (([Int], [Int])
    -> Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
-> ([Int], [Int])
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int])
-> Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
([Int], [Int])
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
aSymBlockTensFac

-- | > aSymBlockATensFac3 = mapTo2 . 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)
aSymBlockATensFac3 :: ([Int], [Int])
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
aSymBlockATensFac3 = (Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 ((Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
 -> AbsTensor3 n1 n2 n3 k1 k2 v
 -> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v))
-> (([Int], [Int])
    -> Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
-> ([Int], [Int])
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int])
-> Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
([Int], [Int])
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
aSymBlockTensFac

-- | > aSymBlockATensFac4 = mapTo3 . 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)
aSymBlockATensFac4 :: ([Int], [Int])
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
aSymBlockATensFac4 = (Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 ((Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v))
-> (([Int], [Int])
    -> Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
-> ([Int], [Int])
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int])
-> Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
([Int], [Int])
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
aSymBlockTensFac

-- | > aSymBlockATensFac5 = mapTo4 . 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)
aSymBlockATensFac5 :: ([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)
aSymBlockATensFac5 = (Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v))
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 ((Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v))
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v))
-> (([Int], [Int])
    -> Tensor n5 k3 v -> Tensor n5 k3 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int])
-> Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
([Int], [Int])
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
aSymBlockTensFac

-- | > aSymBlockATensFac6 = mapTo5 . 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)
aSymBlockATensFac6 :: ([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)
aSymBlockATensFac6 = (Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 ((Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v))
 -> 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))
-> (([Int], [Int])
    -> Tensor n6 k3 v -> Tensor n6 k3 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int])
-> Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
([Int], [Int])
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
aSymBlockTensFac

-- | > aSymBlockATensFac7 = mapTo6 . 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)
aSymBlockATensFac7 :: ([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)
aSymBlockATensFac7 = (Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 ((Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v))
 -> 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))
-> (([Int], [Int])
    -> Tensor n7 k4 v -> Tensor n7 k4 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int])
-> Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
([Int], [Int])
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
aSymBlockTensFac

-- | > aSymBlockATensFac8 = mapTo7 . 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)
aSymBlockATensFac8 :: ([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)
aSymBlockATensFac8 = (Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4.
(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
mapTo7 ((Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v))
 -> 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))
-> (([Int], [Int])
    -> Tensor n8 k4 v -> Tensor n8 k4 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [Int])
-> Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
([Int], [Int])
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
aSymBlockTensFac

--helper function for cyclic symmetrization: convert all permutations of a given list of indices into an equivalent lists of lists of Swaps of 2 indices

getAllSwaps :: [Int] -> [[(Int,Int)]]
getAllSwaps :: [Int] -> [[(Int, Int)]]
getAllSwaps [Int
x,Int
y] = [[(Int
x,Int
y)]]
getAllSwaps (Int
x:[Int]
xs) = [[(Int, Int)]]
lNew [[(Int, Int)]] -> [[(Int, Int)]] -> [[(Int, Int)]]
forall a. [a] -> [a] -> [a]
++ [[(Int, Int)]]
l' [[(Int, Int)]] -> [[(Int, Int)]] -> [[(Int, Int)]]
forall a. [a] -> [a] -> [a]
++ ((:) ((Int, Int) -> [(Int, Int)] -> [(Int, Int)])
-> [(Int, Int)] -> [[(Int, Int)] -> [(Int, Int)]]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Int, Int)]
l [[(Int, Int)] -> [(Int, Int)]] -> [[(Int, Int)]] -> [[(Int, Int)]]
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [[(Int, Int)]]
l')
        where
            l :: [(Int, Int)]
l = [Int] -> [Int] -> [(Int, Int)]
forall a b. [a] -> [b] -> [(a, b)]
zip (Int -> [Int]
forall a. a -> [a]
repeat Int
x) [Int]
xs
            lNew :: [[(Int, Int)]]
lNew = ((Int, Int) -> [(Int, Int)]) -> [(Int, Int)] -> [[(Int, Int)]]
forall a b. (a -> b) -> [a] -> [b]
map (Int, Int) -> [(Int, Int)]
forall (f :: * -> *) a. Applicative f => a -> f a
pure [(Int, Int)]
l
            l' :: [[(Int, Int)]]
l' = [Int] -> [[(Int, Int)]]
getAllSwaps [Int]
xs
getAllSwaps [Int]
_ = String -> [[(Int, Int)]]
forall a. HasCallStack => String -> a
error String
"cannot get swaps from empty permutations"

getAllBlockSwaps :: [[Int]] -> [[([Int],[Int])]]
getAllBlockSwaps :: [[Int]] -> [[([Int], [Int])]]
getAllBlockSwaps [[Int]
x,[Int]
y] = [[([Int]
x,[Int]
y)]]
getAllBlockSwaps ([Int]
x:[[Int]]
xs) = [[([Int], [Int])]]
lNew [[([Int], [Int])]] -> [[([Int], [Int])]] -> [[([Int], [Int])]]
forall a. [a] -> [a] -> [a]
++ [[([Int], [Int])]]
l' [[([Int], [Int])]] -> [[([Int], [Int])]] -> [[([Int], [Int])]]
forall a. [a] -> [a] -> [a]
++ ((:) (([Int], [Int]) -> [([Int], [Int])] -> [([Int], [Int])])
-> [([Int], [Int])] -> [[([Int], [Int])] -> [([Int], [Int])]]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [([Int], [Int])]
l [[([Int], [Int])] -> [([Int], [Int])]]
-> [[([Int], [Int])]] -> [[([Int], [Int])]]
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [[([Int], [Int])]]
l')
        where
            l :: [([Int], [Int])]
l = [[Int]] -> [[Int]] -> [([Int], [Int])]
forall a b. [a] -> [b] -> [(a, b)]
zip ([Int] -> [[Int]]
forall a. a -> [a]
repeat [Int]
x) [[Int]]
xs
            lNew :: [[([Int], [Int])]]
lNew = (([Int], [Int]) -> [([Int], [Int])])
-> [([Int], [Int])] -> [[([Int], [Int])]]
forall a b. (a -> b) -> [a] -> [b]
map ([Int], [Int]) -> [([Int], [Int])]
forall (f :: * -> *) a. Applicative f => a -> f a
pure [([Int], [Int])]
l
            l' :: [[([Int], [Int])]]
l' = [[Int]] -> [[([Int], [Int])]]
getAllBlockSwaps [[Int]]
xs
getAllBlockSwaps [[Int]]
_ = String -> [[([Int], [Int])]]
forall a. HasCallStack => String -> a
error String
"cannot get swaps from empty permutations"

factorial :: Int -> Int
factorial :: Int -> Int
factorial Int
1 = Int
1
factorial Int
n = Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int -> Int
factorial (Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1)

--cyclic symmetrization

-- | 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.
cyclicSymTens :: (TIndex k, TAdd v) => [Int] -> Tensor n k v -> Tensor n k v
cyclicSymTens :: [Int] -> Tensor n k v -> Tensor n k v
cyclicSymTens [Int]
inds Tensor n k v
t = Tensor n k v
newTens
        where
            swapList :: [[(Int, Int)]]
swapList = [Int] -> [[(Int, Int)]]
getAllSwaps [Int]
inds
            tensList :: [Tensor n k v]
tensList = ([(Int, Int)] -> Tensor n k v) -> [[(Int, Int)]] -> [Tensor n k v]
forall a b. (a -> b) -> [a] -> [b]
map (((Int, Int) -> Tensor n k v -> Tensor n k v)
-> Tensor n k v -> [(Int, Int)] -> Tensor n k v
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (Int, Int) -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
tensorTrans Tensor n k v
t) [[(Int, Int)]]
swapList
            newTens :: Tensor n k v
newTens = (Tensor n k v -> Tensor n k v -> Tensor n k v)
-> Tensor n k v -> [Tensor n k v] -> Tensor n k v
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Tensor n k v -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
(&+) Tensor n k v
t [Tensor n k v]
tensList

-- | > cyclicSymATens1 = cyclicSymTens
cyclicSymATens1 :: (TIndex k1, TAdd v) =>
                   [Int] ->
                   AbsTensor1 n1 k1 v ->
                   AbsTensor1 n1 k1 v
cyclicSymATens1 :: [Int] -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
cyclicSymATens1 = [Int] -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
cyclicSymTens

-- | > cyclicSymATens2 = mapTo1 . cyclicSymTens
cyclicSymATens2 :: (TIndex k1, TAdd v) =>
                   [Int] ->
                   AbsTensor2 n1 n2 k1 v ->
                   AbsTensor2 n1 n2 k1 v
cyclicSymATens2 :: [Int] -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
cyclicSymATens2 = (Tensor n2 k1 v -> Tensor n2 k1 v)
-> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 ((Tensor n2 k1 v -> Tensor n2 k1 v)
 -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v)
-> ([Int] -> Tensor n2 k1 v -> Tensor n2 k1 v)
-> [Int]
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n2 k1 v -> Tensor n2 k1 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
cyclicSymTens

-- | > cyclicSymATens3 = mapTo2 . cyclicSymTens
cyclicSymATens3 :: (TIndex k1, TIndex k2, TAdd v) =>
                   [Int] ->
                   AbsTensor3 n1 n2 n3 k1 k2 v ->
                   AbsTensor3 n1 n2 n3 k1 k2 v
cyclicSymATens3 :: [Int] -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
cyclicSymATens3 = (Tensor n3 k2 v -> Tensor n3 k2 v)
-> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 ((Tensor n3 k2 v -> Tensor n3 k2 v)
 -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v)
-> ([Int] -> Tensor n3 k2 v -> Tensor n3 k2 v)
-> [Int]
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n3 k2 v -> Tensor n3 k2 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
cyclicSymTens

-- | > cyclicSymATens4 = mapTo3 . 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
cyclicSymATens4 :: [Int]
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
cyclicSymATens4 = (Tensor n4 k2 v -> Tensor n4 k2 v)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 ((Tensor n4 k2 v -> Tensor n4 k2 v)
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v)
-> ([Int] -> Tensor n4 k2 v -> Tensor n4 k2 v)
-> [Int]
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n4 k2 v -> Tensor n4 k2 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
cyclicSymTens

-- | > cyclicSymATens5 = mapTo4 . 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
cyclicSymATens5 :: [Int]
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
cyclicSymATens5 = (Tensor n5 k3 v -> Tensor n5 k3 v)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 ((Tensor n5 k3 v -> Tensor n5 k3 v)
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v)
-> ([Int] -> Tensor n5 k3 v -> Tensor n5 k3 v)
-> [Int]
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n5 k3 v -> Tensor n5 k3 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
cyclicSymTens

-- | > cyclicSymATens6 = mapTo5 . 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
cyclicSymATens6 :: [Int]
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
cyclicSymATens6 = (Tensor n6 k3 v -> Tensor n6 k3 v)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 ((Tensor n6 k3 v -> Tensor n6 k3 v)
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> ([Int] -> Tensor n6 k3 v -> Tensor n6 k3 v)
-> [Int]
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n6 k3 v -> Tensor n6 k3 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
cyclicSymTens

-- | > cyclicSymATens7 = mapTo6 . 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
cyclicSymATens7 :: [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
cyclicSymATens7 = (Tensor n7 k4 v -> Tensor n7 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 ((Tensor n7 k4 v -> Tensor n7 k4 v)
 -> 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)
-> ([Int] -> Tensor n7 k4 v -> Tensor n7 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n7 k4 v -> Tensor n7 k4 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
cyclicSymTens

-- | > cyclicSymATens8 = mapTo7 . 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
cyclicSymATens8 :: [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
cyclicSymATens8 = (Tensor n8 k4 v -> Tensor n8 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4.
(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
mapTo7 ((Tensor n8 k4 v -> Tensor n8 k4 v)
 -> 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)
-> ([Int] -> Tensor n8 k4 v -> Tensor n8 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n8 k4 v -> Tensor n8 k4 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
cyclicSymTens

--with factor

-- | 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
cyclicSymTensFac :: (TIndex k, TAdd v, Prod (SField Rational) v) => [Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicSymTensFac :: [Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicSymTensFac [Int]
inds Tensor n k v
t = SField Rational
fac SField Rational
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
forall k s v (n :: Nat).
(TIndex k, Prod s v) =>
s -> Tensor n k v -> Tensor n k (TProd s v)
&. [Int] -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
cyclicSymTens [Int]
inds Tensor n k v
t
        where
            fac :: SField Rational
fac = Rational -> SField Rational
forall a. a -> SField a
SField (Rational
1 Rational -> Rational -> Rational
forall a. Fractional a => a -> a -> a
/ Int -> Rational
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int
factorial (Int -> Int) -> Int -> Int
forall a b. (a -> b) -> a -> b
$ [Int] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Int]
inds) :: Rational)

-- | > cyclicSymATensFac1 = cyclicSymTensFac
cyclicSymATensFac1 :: (TIndex k1, TAdd v, Prod (SField Rational) v) =>
                      [Int] ->
                      AbsTensor1 n1 k1 v ->
                      AbsTensor1 n1 k1 (TProd (SField Rational) v)
cyclicSymATensFac1 :: [Int]
-> AbsTensor1 n1 k1 v
-> AbsTensor1 n1 k1 (TProd (SField Rational) v)
cyclicSymATensFac1 = [Int]
-> AbsTensor1 n1 k1 v
-> AbsTensor1 n1 k1 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicSymTensFac

-- | > cyclicSymATensFac2 = mapTo1 . cyclicSymTensFac
cyclicSymATensFac2 :: (TIndex k1, TAdd v, Prod (SField Rational) v) =>
                      [Int] ->
                      AbsTensor2 n1 n2 k1 v ->
                      AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
cyclicSymATensFac2 :: [Int]
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
cyclicSymATensFac2 = (Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 ((Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
 -> AbsTensor2 n1 n2 k1 v
 -> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v))
-> ([Int]
    -> Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
-> [Int]
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicSymTensFac

-- | > cyclicSymATensFac3 = mapTo2 . 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)
cyclicSymATensFac3 :: [Int]
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
cyclicSymATensFac3 = (Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 ((Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
 -> AbsTensor3 n1 n2 n3 k1 k2 v
 -> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v))
-> ([Int]
    -> Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
-> [Int]
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicSymTensFac

-- | > cyclicSymATensFac4 = mapTo3 . 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)
cyclicSymATensFac4 :: [Int]
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
cyclicSymATensFac4 = (Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 ((Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v))
-> ([Int]
    -> Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
-> [Int]
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicSymTensFac

-- | > cyclicSymATensFac5 = mapTo4 . 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)
cyclicSymATensFac5 :: [Int]
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v)
cyclicSymATensFac5 = (Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v))
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 ((Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v))
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v))
-> ([Int]
    -> Tensor n5 k3 v -> Tensor n5 k3 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicSymTensFac

-- | > cyclicSymATensFac6 = mapTo5 . 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)
cyclicSymATensFac6 :: [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)
cyclicSymATensFac6 = (Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 ((Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v))
 -> 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))
-> ([Int]
    -> Tensor n6 k3 v -> Tensor n6 k3 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicSymTensFac

-- | > cyclicSymATensFac7 = mapTo6 . 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)
cyclicSymATensFac7 :: [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)
cyclicSymATensFac7 = (Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 ((Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v))
 -> 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))
-> ([Int]
    -> Tensor n7 k4 v -> Tensor n7 k4 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicSymTensFac

-- | > cyclicSymATensFac8 = mapTo7 . 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)
cyclicSymATensFac8 :: [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)
cyclicSymATensFac8 = (Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4.
(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
mapTo7 ((Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v))
 -> 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))
-> ([Int]
    -> Tensor n8 k4 v -> Tensor n8 k4 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicSymTensFac

--cyclic anti symmetrization

-- | 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.
cyclicASymTens :: (TIndex k, TAdd v) => [Int] -> Tensor n k v -> Tensor n k v
cyclicASymTens :: [Int] -> Tensor n k v -> Tensor n k v
cyclicASymTens [Int]
inds Tensor n k v
t = Tensor n k v
newTens
        where
            swapList :: [[(Int, Int)]]
swapList = [Int] -> [[(Int, Int)]]
getAllSwaps [Int]
inds
            signList :: [Integer]
signList = ([(Int, Int)] -> Integer) -> [[(Int, Int)]] -> [Integer]
forall a b. (a -> b) -> [a] -> [b]
map (\[(Int, Int)]
x -> (-Integer
1 :: Integer) Integer -> Int -> Integer
forall a b. (Num a, Integral b) => a -> b -> a
^ [(Int, Int)] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [(Int, Int)]
x) [[(Int, Int)]]
swapList
            tensList' :: [Tensor n k v]
tensList' = ([(Int, Int)] -> Tensor n k v) -> [[(Int, Int)]] -> [Tensor n k v]
forall a b. (a -> b) -> [a] -> [b]
map (((Int, Int) -> Tensor n k v -> Tensor n k v)
-> Tensor n k v -> [(Int, Int)] -> Tensor n k v
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (Int, Int) -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor n k v -> Tensor n k v
tensorTrans Tensor n k v
t) [[(Int, Int)]]
swapList
            tensList :: [Tensor n k v]
tensList = (Integer -> Tensor n k v -> Tensor n k v)
-> [Integer] -> [Tensor n k v] -> [Tensor n k v]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith (\Integer
s Tensor n k v
v -> if Integer
s Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
== -Integer
1 then Tensor n k v -> Tensor n k v
forall a. TAdd a => a -> a
negateS Tensor n k v
v else Tensor n k v
v) [Integer]
signList [Tensor n k v]
tensList'
            newTens :: Tensor n k v
newTens = (Tensor n k v -> Tensor n k v -> Tensor n k v)
-> Tensor n k v -> [Tensor n k v] -> Tensor n k v
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Tensor n k v -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
(&+) Tensor n k v
t [Tensor n k v]
tensList

-- | > cyclicASymATens1 = cyclicASymTens
cyclicASymATens1 :: (TIndex k1, TAdd v) =>
                    [Int] ->
                    AbsTensor1 n1 k1 v ->
                    AbsTensor1 n1 k1 v
cyclicASymATens1 :: [Int] -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
cyclicASymATens1 = [Int] -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
cyclicASymTens

-- | > cyclicASymATens2 = mapTo1 . cyclicASymTens
cyclicASymATens2 :: (TIndex k1, TAdd v) =>
                    [Int] ->
                    AbsTensor2 n1 n2 k1 v ->
                    AbsTensor2 n1 n2 k1 v
cyclicASymATens2 :: [Int] -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
cyclicASymATens2 = (Tensor n2 k1 v -> Tensor n2 k1 v)
-> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 ((Tensor n2 k1 v -> Tensor n2 k1 v)
 -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v)
-> ([Int] -> Tensor n2 k1 v -> Tensor n2 k1 v)
-> [Int]
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n2 k1 v -> Tensor n2 k1 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
cyclicASymTens

-- | > cyclicASymATens3 = mapTo2 . cyclicASymTens
cyclicASymATens3 :: (TIndex k1, TIndex k2, TAdd v) =>
                    [Int] ->
                    AbsTensor3 n1 n2 n3 k1 k2 v ->
                    AbsTensor3 n1 n2 n3 k1 k2 v
cyclicASymATens3 :: [Int] -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
cyclicASymATens3 = (Tensor n3 k2 v -> Tensor n3 k2 v)
-> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 ((Tensor n3 k2 v -> Tensor n3 k2 v)
 -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v)
-> ([Int] -> Tensor n3 k2 v -> Tensor n3 k2 v)
-> [Int]
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n3 k2 v -> Tensor n3 k2 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
cyclicASymTens

-- | > cyclicASymATens4 = mapTo3 . 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
cyclicASymATens4 :: [Int]
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
cyclicASymATens4 = (Tensor n4 k2 v -> Tensor n4 k2 v)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 ((Tensor n4 k2 v -> Tensor n4 k2 v)
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v)
-> ([Int] -> Tensor n4 k2 v -> Tensor n4 k2 v)
-> [Int]
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n4 k2 v -> Tensor n4 k2 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
cyclicASymTens

-- | > cyclicASymATens5 = mapTo4 . 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
cyclicASymATens5 :: [Int]
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
cyclicASymATens5 = (Tensor n5 k3 v -> Tensor n5 k3 v)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 ((Tensor n5 k3 v -> Tensor n5 k3 v)
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v)
-> ([Int] -> Tensor n5 k3 v -> Tensor n5 k3 v)
-> [Int]
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n5 k3 v -> Tensor n5 k3 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
cyclicASymTens

-- | > cyclicASymATens6 = mapTo5 . 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
cyclicASymATens6 :: [Int]
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
cyclicASymATens6 = (Tensor n6 k3 v -> Tensor n6 k3 v)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 ((Tensor n6 k3 v -> Tensor n6 k3 v)
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> ([Int] -> Tensor n6 k3 v -> Tensor n6 k3 v)
-> [Int]
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n6 k3 v -> Tensor n6 k3 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
cyclicASymTens

-- | > cyclicASymATens7 = mapTo6 . 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
cyclicASymATens7 :: [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
cyclicASymATens7 = (Tensor n7 k4 v -> Tensor n7 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 ((Tensor n7 k4 v -> Tensor n7 k4 v)
 -> 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)
-> ([Int] -> Tensor n7 k4 v -> Tensor n7 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n7 k4 v -> Tensor n7 k4 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
cyclicASymTens

-- | > cyclicASymATens8 = mapTo7 . 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
cyclicASymATens8 :: [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
cyclicASymATens8 = (Tensor n8 k4 v -> Tensor n8 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4.
(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
mapTo7 ((Tensor n8 k4 v -> Tensor n8 k4 v)
 -> 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)
-> ([Int] -> Tensor n8 k4 v -> Tensor n8 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n8 k4 v -> Tensor n8 k4 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
cyclicASymTens

--with factor

-- | 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
cyclicASymTensFac :: (TIndex k, TAdd v, Prod (SField Rational) v) => [Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicASymTensFac :: [Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicASymTensFac [Int]
inds Tensor n k v
t = SField Rational
fac SField Rational
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
forall k s v (n :: Nat).
(TIndex k, Prod s v) =>
s -> Tensor n k v -> Tensor n k (TProd s v)
&. [Int] -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[Int] -> Tensor n k v -> Tensor n k v
cyclicASymTens [Int]
inds Tensor n k v
t
        where
            fac :: SField Rational
fac = Rational -> SField Rational
forall a. a -> SField a
SField (Rational
1 Rational -> Rational -> Rational
forall a. Fractional a => a -> a -> a
/ Int -> Rational
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int
factorial (Int -> Int) -> Int -> Int
forall a b. (a -> b) -> a -> b
$ [Int] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Int]
inds) :: Rational)

-- | > cyclicASymATensFac1 = cyclicASymTensFac
cyclicASymATensFac1 :: (TIndex k1, TAdd v, Prod (SField Rational) v) =>
                       [Int] ->
                       AbsTensor1 n1 k1 v ->
                       AbsTensor1 n1 k1 (TProd (SField Rational) v)
cyclicASymATensFac1 :: [Int]
-> AbsTensor1 n1 k1 v
-> AbsTensor1 n1 k1 (TProd (SField Rational) v)
cyclicASymATensFac1 = [Int]
-> AbsTensor1 n1 k1 v
-> AbsTensor1 n1 k1 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicASymTensFac

-- | > cyclicASymATensFac2 = mapTo1 . cyclicASymTensFac
cyclicASymATensFac2 :: (TIndex k1, TAdd v, Prod (SField Rational) v) =>
                       [Int] ->
                       AbsTensor2 n1 n2 k1 v ->
                       AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
cyclicASymATensFac2 :: [Int]
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
cyclicASymATensFac2 = (Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 ((Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
 -> AbsTensor2 n1 n2 k1 v
 -> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v))
-> ([Int]
    -> Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
-> [Int]
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicASymTensFac

-- | > cyclicASymATensFac3 = mapTo2 . 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)
cyclicASymATensFac3 :: [Int]
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
cyclicASymATensFac3 = (Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 ((Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
 -> AbsTensor3 n1 n2 n3 k1 k2 v
 -> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v))
-> ([Int]
    -> Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
-> [Int]
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicASymTensFac

-- | > cyclicASymATensFac4 = mapTo3 . 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)
cyclicASymATensFac4 :: [Int]
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
cyclicASymATensFac4 = (Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 ((Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v))
-> ([Int]
    -> Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
-> [Int]
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicASymTensFac

-- | > cyclicASymATensFac5 = mapTo4 . 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)
cyclicASymATensFac5 :: [Int]
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v)
cyclicASymATensFac5 = (Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v))
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 ((Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v))
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v))
-> ([Int]
    -> Tensor n5 k3 v -> Tensor n5 k3 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicASymTensFac

-- | > cyclicASymATensFac6 = mapTo5 . 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)
cyclicASymATensFac6 :: [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)
cyclicASymATensFac6 = (Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 ((Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v))
 -> 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))
-> ([Int]
    -> Tensor n6 k3 v -> Tensor n6 k3 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicASymTensFac

-- | > cyclicASymATensFac7 = mapTo6 . 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)
cyclicASymATensFac7 :: [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)
cyclicASymATensFac7 = (Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 ((Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v))
 -> 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))
-> ([Int]
    -> Tensor n7 k4 v -> Tensor n7 k4 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicASymTensFac

-- | > cyclicASymATensFac8 = mapTo7 . 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)
cyclicASymATensFac8 :: [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)
cyclicASymATensFac8 = (Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4.
(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
mapTo7 ((Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v))
 -> 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))
-> ([Int]
    -> Tensor n8 k4 v -> Tensor n8 k4 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[Int] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicASymTensFac

--cyclic block symmetrization

-- | 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.
cyclicBlockSymTens :: (TIndex k, TAdd v) => [[Int]] -> Tensor n k v -> Tensor n k v
cyclicBlockSymTens :: [[Int]] -> Tensor n k v -> Tensor n k v
cyclicBlockSymTens [[Int]]
inds Tensor n k v
t = Tensor n k v
newTens
        where
            swapList :: [[([Int], [Int])]]
swapList = [[Int]] -> [[([Int], [Int])]]
getAllBlockSwaps [[Int]]
inds
            tensList :: [Tensor n k v]
tensList = ([([Int], [Int])] -> Tensor n k v)
-> [[([Int], [Int])]] -> [Tensor n k v]
forall a b. (a -> b) -> [a] -> [b]
map ((([Int], [Int]) -> Tensor n k v -> Tensor n k v)
-> Tensor n k v -> [([Int], [Int])] -> Tensor n k v
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr ([Int], [Int]) -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
([Int], [Int]) -> Tensor n k v -> Tensor n k v
tensorBlockTrans Tensor n k v
t) [[([Int], [Int])]]
swapList
            newTens :: Tensor n k v
newTens = (Tensor n k v -> Tensor n k v -> Tensor n k v)
-> Tensor n k v -> [Tensor n k v] -> Tensor n k v
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Tensor n k v -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
(&+) Tensor n k v
t [Tensor n k v]
tensList

-- | > cyclicBlockSymATens1 = cyclicBlockSymTens
cyclicBlockSymATens1 :: (TIndex k1, TAdd v) =>
                        [[Int]] ->
                        AbsTensor1 n1 k1 v ->
                        AbsTensor1 n1 k1 v
cyclicBlockSymATens1 :: [[Int]] -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
cyclicBlockSymATens1 = [[Int]] -> AbsTensor1 n1 k1 v -> AbsTensor1 n1 k1 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[[Int]] -> Tensor n k v -> Tensor n k v
cyclicBlockSymTens

-- | > cyclicBlockSymATens2 = mapTo1 . cyclicBlockSymTens
cyclicBlockSymATens2 :: (TIndex k1, TAdd v) =>
                        [[Int]] ->
                        AbsTensor2 n1 n2 k1 v ->
                        AbsTensor2 n1 n2 k1 v
cyclicBlockSymATens2 :: [[Int]] -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
cyclicBlockSymATens2 = (Tensor n2 k1 v -> Tensor n2 k1 v)
-> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 ((Tensor n2 k1 v -> Tensor n2 k1 v)
 -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v)
-> ([[Int]] -> Tensor n2 k1 v -> Tensor n2 k1 v)
-> [[Int]]
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Int]] -> Tensor n2 k1 v -> Tensor n2 k1 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[[Int]] -> Tensor n k v -> Tensor n k v
cyclicBlockSymTens

-- | > cyclicBlockSymATens3 = mapTo2 . cyclicBlockSymTens
cyclicBlockSymATens3 :: (TIndex k1, TIndex k2, TAdd v) =>
                        [[Int]] ->
                        AbsTensor3 n1 n2 n3 k1 k2 v ->
                        AbsTensor3 n1 n2 n3 k1 k2 v
cyclicBlockSymATens3 :: [[Int]]
-> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
cyclicBlockSymATens3 = (Tensor n3 k2 v -> Tensor n3 k2 v)
-> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 ((Tensor n3 k2 v -> Tensor n3 k2 v)
 -> AbsTensor3 n1 n2 n3 k1 k2 v -> AbsTensor3 n1 n2 n3 k1 k2 v)
-> ([[Int]] -> Tensor n3 k2 v -> Tensor n3 k2 v)
-> [[Int]]
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Int]] -> Tensor n3 k2 v -> Tensor n3 k2 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[[Int]] -> Tensor n k v -> Tensor n k v
cyclicBlockSymTens

-- | > cyclicBlockSymATens4 = mapTo3 . 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
cyclicBlockSymATens4 :: [[Int]]
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
cyclicBlockSymATens4 = (Tensor n4 k2 v -> Tensor n4 k2 v)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 ((Tensor n4 k2 v -> Tensor n4 k2 v)
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v)
-> ([[Int]] -> Tensor n4 k2 v -> Tensor n4 k2 v)
-> [[Int]]
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Int]] -> Tensor n4 k2 v -> Tensor n4 k2 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[[Int]] -> Tensor n k v -> Tensor n k v
cyclicBlockSymTens

-- | > cyclicBlockSymATens5 = mapTo4 . 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
cyclicBlockSymATens5 :: [[Int]]
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
cyclicBlockSymATens5 = (Tensor n5 k3 v -> Tensor n5 k3 v)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 ((Tensor n5 k3 v -> Tensor n5 k3 v)
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v)
-> ([[Int]] -> Tensor n5 k3 v -> Tensor n5 k3 v)
-> [[Int]]
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Int]] -> Tensor n5 k3 v -> Tensor n5 k3 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[[Int]] -> Tensor n k v -> Tensor n k v
cyclicBlockSymTens

-- | > cyclicBlockSymATens6 = mapTo5 . 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
cyclicBlockSymATens6 :: [[Int]]
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
cyclicBlockSymATens6 = (Tensor n6 k3 v -> Tensor n6 k3 v)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 ((Tensor n6 k3 v -> Tensor n6 k3 v)
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> ([[Int]] -> Tensor n6 k3 v -> Tensor n6 k3 v)
-> [[Int]]
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Int]] -> Tensor n6 k3 v -> Tensor n6 k3 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[[Int]] -> Tensor n k v -> Tensor n k v
cyclicBlockSymTens

-- | > cyclicBlockSymATens7 = mapTo6 . 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
cyclicBlockSymATens7 :: [[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
cyclicBlockSymATens7 = (Tensor n7 k4 v -> Tensor n7 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 ((Tensor n7 k4 v -> Tensor n7 k4 v)
 -> 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)
-> ([[Int]] -> Tensor n7 k4 v -> Tensor n7 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Int]] -> Tensor n7 k4 v -> Tensor n7 k4 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[[Int]] -> Tensor n k v -> Tensor n k v
cyclicBlockSymTens

-- | > cyclicBlockSymATens8 = mapTo7 . 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
cyclicBlockSymATens8 :: [[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
cyclicBlockSymATens8 = (Tensor n8 k4 v -> Tensor n8 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4.
(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
mapTo7 ((Tensor n8 k4 v -> Tensor n8 k4 v)
 -> 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)
-> ([[Int]] -> Tensor n8 k4 v -> Tensor n8 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Int]] -> Tensor n8 k4 v -> Tensor n8 k4 v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[[Int]] -> Tensor n k v -> Tensor n k v
cyclicBlockSymTens

--with factor

-- | 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
cyclicBlockSymTensFac :: (TIndex k, TAdd v, Prod (SField Rational) v) => [[Int]] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicBlockSymTensFac :: [[Int]] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicBlockSymTensFac [[Int]]
inds Tensor n k v
t = SField Rational
fac SField Rational
-> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
forall k s v (n :: Nat).
(TIndex k, Prod s v) =>
s -> Tensor n k v -> Tensor n k (TProd s v)
&. [[Int]] -> Tensor n k v -> Tensor n k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[[Int]] -> Tensor n k v -> Tensor n k v
cyclicBlockSymTens [[Int]]
inds Tensor n k v
t
        where
            fac :: SField Rational
fac = Rational -> SField Rational
forall a. a -> SField a
SField (Rational
1 Rational -> Rational -> Rational
forall a. Fractional a => a -> a -> a
/ Int -> Rational
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int
factorial (Int -> Int) -> Int -> Int
forall a b. (a -> b) -> a -> b
$ [[Int]] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [[Int]]
inds) :: Rational)

-- | > cyclicBlockSymATensFac1 = cyclicBlockSymTensFac
cyclicBlockSymATensFac1 :: (TIndex k1, TAdd v, Prod (SField Rational) v) =>
                           [[Int]] ->
                           AbsTensor1 n1 k1 v ->
                           AbsTensor1 n1 k1 (TProd (SField Rational) v)
cyclicBlockSymATensFac1 :: [[Int]]
-> AbsTensor1 n1 k1 v
-> AbsTensor1 n1 k1 (TProd (SField Rational) v)
cyclicBlockSymATensFac1 = [[Int]]
-> AbsTensor1 n1 k1 v
-> AbsTensor1 n1 k1 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[[Int]] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicBlockSymTensFac

-- | > cyclicBlockSymATensFac2 = mapTo1 . cyclicBlockSymTensFac
cyclicBlockSymATensFac2 :: (TIndex k1, TAdd v, Prod (SField Rational) v) =>
                           [[Int]] ->
                           AbsTensor2 n1 n2 k1 v ->
                           AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
cyclicBlockSymATensFac2 :: [[Int]]
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
cyclicBlockSymATensFac2 = (Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) k.
(v1 -> v2) -> Tensor n1 k v1 -> Tensor n1 k v2
mapTo1 ((Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
 -> AbsTensor2 n1 n2 k1 v
 -> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v))
-> ([[Int]]
    -> Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v))
-> [[Int]]
-> AbsTensor2 n1 n2 k1 v
-> AbsTensor2 n1 n2 k1 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Int]]
-> Tensor n2 k1 v -> Tensor n2 k1 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[[Int]] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicBlockSymTensFac

-- | > cyclicBlockSymATensFac3 = mapTo2 . 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)
cyclicBlockSymATensFac3 :: [[Int]]
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
cyclicBlockSymATensFac3 = (Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 ((Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
 -> AbsTensor3 n1 n2 n3 k1 k2 v
 -> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v))
-> ([[Int]]
    -> Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v))
-> [[Int]]
-> AbsTensor3 n1 n2 n3 k1 k2 v
-> AbsTensor3 n1 n2 n3 k1 k2 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Int]]
-> Tensor n3 k2 v -> Tensor n3 k2 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[[Int]] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicBlockSymTensFac

-- | > cyclicBlockSymATensFac4 = mapTo3 . 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)
cyclicBlockSymATensFac4 :: [[Int]]
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
cyclicBlockSymATensFac4 = (Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor3 n1 n2 n3 k1 k2 v1 -> AbsTensor3 n1 n2 n3 k1 k2 v2
mapTo3 ((Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v))
-> ([[Int]]
    -> Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v))
-> [[Int]]
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 (TProd (SField Rational) v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Int]]
-> Tensor n4 k2 v -> Tensor n4 k2 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[[Int]] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicBlockSymTensFac

-- | > cyclicBlockSymATensFac5 = mapTo4 . 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)
cyclicBlockSymATensFac5 :: [[Int]]
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v)
cyclicBlockSymATensFac5 = (Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v))
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 ((Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v))
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
 -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (TProd (SField Rational) v))
-> ([[Int]]
    -> Tensor n5 k3 v -> Tensor n5 k3 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Int]]
-> Tensor n5 k3 v -> Tensor n5 k3 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[[Int]] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicBlockSymTensFac

-- | > cyclicBlockSymATensFac6 = mapTo5 . 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)
cyclicBlockSymATensFac6 :: [[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)
cyclicBlockSymATensFac6 = (Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v1
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v2
mapTo5 ((Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v))
 -> 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))
-> ([[Int]]
    -> Tensor n6 k3 v -> Tensor n6 k3 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Int]]
-> Tensor n6 k3 v -> Tensor n6 k3 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[[Int]] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicBlockSymTensFac

-- | > cyclicBlockSymATensFac7 = mapTo6 . 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)
cyclicBlockSymATensFac7 :: [[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)
cyclicBlockSymATensFac7 = (Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 ((Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v))
 -> 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))
-> ([[Int]]
    -> Tensor n7 k4 v -> Tensor n7 k4 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Int]]
-> Tensor n7 k4 v -> Tensor n7 k4 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[[Int]] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicBlockSymTensFac

-- | > cyclicBlockSymATensFac8 = mapTo7 . 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)
cyclicBlockSymATensFac8 :: [[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)
cyclicBlockSymATensFac8 = (Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v))
-> 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)
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4.
(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
mapTo7 ((Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v))
 -> 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))
-> ([[Int]]
    -> Tensor n8 k4 v -> Tensor n8 k4 (TProd (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)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Int]]
-> Tensor n8 k4 v -> Tensor n8 k4 (TProd (SField Rational) v)
forall k v (n :: Nat).
(TIndex k, TAdd v, Prod (SField Rational) v) =>
[[Int]] -> Tensor n k v -> Tensor n k (TProd (SField Rational) v)
cyclicBlockSymTensFac

--contraction for general tensors

-- | 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.
tensorContr :: (TIndex k, TAdd v) => (Int,Int) -> Tensor2 n1 n2 k v -> Tensor2 (n1-1) (n2-1) k v
tensorContr :: (Int, Int) -> Tensor2 n1 n2 k v -> Tensor2 (n1 - 1) (n2 - 1) k v
tensorContr (Int
0,Int
j) Tensor2 n1 n2 k v
t = [(IndList (n1 - 1) k, Tensor (n2 - 1) k v)]
-> Tensor2 (n1 - 1) (n2 - 1) k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[(IndList n k, v)] -> Tensor n k v
fromListT [(IndList (n1 - 1) k, Tensor (n2 - 1) k v)]
tensList
    where
        l :: [(IndList n1 k, [(IndList n2 k, v)])]
l = ((IndList n1 k, Tensor n2 k v)
 -> (IndList n1 k, [(IndList n2 k, v)]))
-> [(IndList n1 k, Tensor n2 k v)]
-> [(IndList n1 k, [(IndList n2 k, v)])]
forall a b. (a -> b) -> [a] -> [b]
map (\(IndList n1 k
x,Tensor n2 k v
y) -> (IndList n1 k
x, Tensor n2 k v -> [(IndList n2 k, v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n2 k v
y)) ([(IndList n1 k, Tensor n2 k v)]
 -> [(IndList n1 k, [(IndList n2 k, v)])])
-> [(IndList n1 k, Tensor n2 k v)]
-> [(IndList n1 k, [(IndList n2 k, v)])]
forall a b. (a -> b) -> a -> b
$ Tensor2 n1 n2 k v -> [(IndList n1 k, Tensor n2 k v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor2 n1 n2 k v
t
        l2 :: [(IndList (n1 - 1) k, [(IndList (n2 - 1) k, v)])]
l2 = ((IndList n1 k, [(IndList n2 k, v)])
 -> (IndList (n1 - 1) k, [(IndList (n2 - 1) k, v)]))
-> [(IndList n1 k, [(IndList n2 k, v)])]
-> [(IndList (n1 - 1) k, [(IndList (n2 - 1) k, v)])]
forall a b. (a -> b) -> [a] -> [b]
map (\(IndList n1 k
x,[(IndList n2 k, v)]
y) -> (IndList n1 k -> IndList (n1 - 1) k
forall (n :: Nat) a. IndList n a -> IndList (n - 1) a
tailInd IndList n1 k
x,((IndList n2 k, v) -> Maybe (IndList (n2 - 1) k, v))
-> [(IndList n2 k, v)] -> [(IndList (n2 - 1) k, v)]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Int -> k -> (IndList n2 k, v) -> Maybe (IndList (n2 - 1) k, v)
forall a (n :: Nat) c.
Eq a =>
Int -> a -> (IndList n a, c) -> Maybe (IndList (n - 1) a, c)
removeContractionInd Int
j (IndList n1 k -> k
forall (n :: Nat) a. IndList n a -> a
headInd IndList n1 k
x)) [(IndList n2 k, v)]
y)) [(IndList n1 k, [(IndList n2 k, v)])]
l
        l3 :: [(IndList (n1 - 1) k, [(IndList (n2 - 1) k, v)])]
l3 = ((IndList (n1 - 1) k, [(IndList (n2 - 1) k, v)]) -> Bool)
-> [(IndList (n1 - 1) k, [(IndList (n2 - 1) k, v)])]
-> [(IndList (n1 - 1) k, [(IndList (n2 - 1) k, v)])]
forall a. (a -> Bool) -> [a] -> [a]
filter (\(IndList (n1 - 1) k
_,[(IndList (n2 - 1) k, v)]
y) -> Bool -> Bool
not ([(IndList (n2 - 1) k, v)] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(IndList (n2 - 1) k, v)]
y)) [(IndList (n1 - 1) k, [(IndList (n2 - 1) k, v)])]
l2
        tensList :: [(IndList (n1 - 1) k, Tensor (n2 - 1) k v)]
tensList = ((IndList (n1 - 1) k, [(IndList (n2 - 1) k, v)])
 -> (IndList (n1 - 1) k, Tensor (n2 - 1) k v))
-> [(IndList (n1 - 1) k, [(IndList (n2 - 1) k, v)])]
-> [(IndList (n1 - 1) k, Tensor (n2 - 1) k v)]
forall a b. (a -> b) -> [a] -> [b]
map (\(IndList (n1 - 1) k
x,[(IndList (n2 - 1) k, v)]
y) -> (IndList (n1 - 1) k
x, [(IndList (n2 - 1) k, v)] -> Tensor (n2 - 1) k v
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
[(IndList n k, v)] -> Tensor n k v
fromListT [(IndList (n2 - 1) k, v)]
y)) [(IndList (n1 - 1) k, [(IndList (n2 - 1) k, v)])]
l3
tensorContr (Int
i,Int
j) (Tensor TMap k (Tensor n k (Tensor n2 k v))
m) = TMap k (Tensor (n - 1) k (Tensor (n2 - 1) k v))
-> Tensor ((n - 1) + 1) k (Tensor (n2 - 1) k v)
forall k (n :: Nat) v. TMap k (Tensor n k v) -> Tensor (n + 1) k v
Tensor (TMap k (Tensor (n - 1) k (Tensor (n2 - 1) k v))
 -> Tensor ((n - 1) + 1) k (Tensor (n2 - 1) k v))
-> TMap k (Tensor (n - 1) k (Tensor (n2 - 1) k v))
-> Tensor ((n - 1) + 1) k (Tensor (n2 - 1) k v)
forall a b. (a -> b) -> a -> b
$ (Tensor n k (Tensor n2 k v)
 -> Tensor (n - 1) k (Tensor (n2 - 1) k v))
-> TMap k (Tensor n k (Tensor n2 k v))
-> TMap k (Tensor (n - 1) k (Tensor (n2 - 1) k v))
forall v v' k. (v -> v') -> TMap k v -> TMap k v'
mapTMap ((Int, Int)
-> Tensor n k (Tensor n2 k v)
-> Tensor (n - 1) k (Tensor (n2 - 1) k v)
forall k v (n1 :: Nat) (n2 :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor2 n1 n2 k v -> Tensor2 (n1 - 1) (n2 - 1) k v
tensorContr (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1,Int
j)) TMap k (Tensor n k (Tensor n2 k v))
m
tensorContr (Int, Int)
_ Tensor2 n1 n2 k v
ZeroTensor = Tensor2 (n1 - 1) (n2 - 1) k v
forall (n :: Nat) k v. Tensor n k v
ZeroTensor
tensorContr (Int, Int)
_ (Scalar Tensor n2 k v
_) = String -> Tensor (0 - 1) k (Tensor (n2 - 1) k v)
forall a. HasCallStack => String -> a
error String
"cannot contract scalar!"

-- | @'contrATens1'@ is a synonym for @'tensorContr'@. It applies the contraction to the 1st index type of a tensor.
--
-- > contrATens1 = tensorContr
contrATens1 :: (TIndex k1, TAdd v) => (Int,Int) -> AbsTensor2 (n1+1) (n2+1) k1 v -> AbsTensor2 n1 n2 k1 v
contrATens1 :: (Int, Int)
-> AbsTensor2 (n1 + 1) (n2 + 1) k1 v -> AbsTensor2 n1 n2 k1 v
contrATens1 = (Int, Int)
-> AbsTensor2 (n1 + 1) (n2 + 1) k1 v -> AbsTensor2 n1 n2 k1 v
forall k v (n1 :: Nat) (n2 :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor2 n1 n2 k v -> Tensor2 (n1 - 1) (n2 - 1) k v
tensorContr

-- | @'contrATens2'@ applies the contraction to the 2nd index type of a tensor.
--
-- > contrATens2 = mapTo2 . 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
contrATens2 :: (Int, Int)
-> AbsTensor4 n1 n2 (n3 + 1) (n4 + 1) k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
contrATens2 = (Tensor2 (n3 + 1) (n4 + 1) k2 v -> Tensor2 n3 n4 k2 v)
-> AbsTensor4 n1 n2 (n3 + 1) (n4 + 1) k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) k.
(v1 -> v2) -> Tensor2 n1 n2 k v1 -> Tensor2 n1 n2 k v2
mapTo2 ((Tensor2 (n3 + 1) (n4 + 1) k2 v -> Tensor2 n3 n4 k2 v)
 -> AbsTensor4 n1 n2 (n3 + 1) (n4 + 1) k1 k2 v
 -> AbsTensor4 n1 n2 n3 n4 k1 k2 v)
-> ((Int, Int)
    -> Tensor2 (n3 + 1) (n4 + 1) k2 v -> Tensor2 n3 n4 k2 v)
-> (Int, Int)
-> AbsTensor4 n1 n2 (n3 + 1) (n4 + 1) k1 k2 v
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor2 (n3 + 1) (n4 + 1) k2 v -> Tensor2 n3 n4 k2 v
forall k v (n1 :: Nat) (n2 :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor2 n1 n2 k v -> Tensor2 (n1 - 1) (n2 - 1) k v
tensorContr

-- | @'contrATens3'@ applies the contraction to the 3rd index type of a tensor.
--
-- > contrATens3 = mapTo4 . 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
contrATens3 :: (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
contrATens3 = (Tensor2 (n5 + 1) (n6 + 1) k3 v -> Tensor2 n5 n6 k3 v)
-> AbsTensor6 n1 n2 n3 n4 (n5 + 1) (n6 + 1) k1 k2 k3 v
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2.
(v1 -> v2)
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v1
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v2
mapTo4 ((Tensor2 (n5 + 1) (n6 + 1) k3 v -> Tensor2 n5 n6 k3 v)
 -> AbsTensor6 n1 n2 n3 n4 (n5 + 1) (n6 + 1) k1 k2 k3 v
 -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v)
-> ((Int, Int)
    -> Tensor2 (n5 + 1) (n6 + 1) k3 v -> Tensor2 n5 n6 k3 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor2 (n5 + 1) (n6 + 1) k3 v -> Tensor2 n5 n6 k3 v
forall k v (n1 :: Nat) (n2 :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor2 n1 n2 k v -> Tensor2 (n1 - 1) (n2 - 1) k v
tensorContr

-- | @'contrATens4'@ applies the contraction to the 4th index type of a tensor.
--
-- > contrATens4 = mapTo6 . 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
contrATens4 :: (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
contrATens4 = (Tensor2 (n7 + 1) (n8 + 1) k4 v -> Tensor2 n7 n8 k4 v)
-> 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
forall v1 v2 (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat) k1 k2 k3.
(v1 -> v2)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v1
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v2
mapTo6 ((Tensor2 (n7 + 1) (n8 + 1) k4 v -> Tensor2 n7 n8 k4 v)
 -> 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)
-> ((Int, Int)
    -> Tensor2 (n7 + 1) (n8 + 1) k4 v -> Tensor2 n7 n8 k4 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
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Tensor2 (n7 + 1) (n8 + 1) k4 v -> Tensor2 n7 n8 k4 v
forall k v (n1 :: Nat) (n2 :: Nat).
(TIndex k, TAdd v) =>
(Int, Int) -> Tensor2 n1 n2 k v -> Tensor2 (n1 - 1) (n2 - 1) k v
tensorContr

--construct tensors from lists of (indices,value) pairs

type IndTuple1 n1 k1 = IndList n1 k1

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

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

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

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)

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)

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)

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)

--construct a tensor with a single value

_mkTens1 :: (IndTuple1 n1 k1, v) -> AbsTensor1 n1 k1 v
_mkTens1 :: (IndTuple1 n1 k1, v) -> AbsTensor1 n1 k1 v
_mkTens1 = (IndTuple1 n1 k1, v) -> AbsTensor1 n1 k1 v
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens

mkTens2 :: (IndTuple2 n1 n2 k1, v) -> AbsTensor2 n1 n2 k1 v
mkTens2 :: (IndTuple2 n1 n2 k1, v) -> AbsTensor2 n1 n2 k1 v
mkTens2 ((IndList n1 k1
i1,IndList n2 k1
i2),v
s) = (IndList n1 k1, Tensor n2 k1 v) -> AbsTensor2 n1 n2 k1 v
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n1 k1
i1,(IndList n2 k1, v) -> Tensor n2 k1 v
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n2 k1
i2,v
s))

mkTens3 :: (IndTuple3 n1 n2 n3 k1 k2, v) -> AbsTensor3 n1 n2 n3 k1 k2 v
mkTens3 :: (IndTuple3 n1 n2 n3 k1 k2, v) -> AbsTensor3 n1 n2 n3 k1 k2 v
mkTens3 ((IndList n1 k1
i1,IndList n2 k1
i2,IndList n3 k2
i3),v
s) = (IndList n1 k1, Tensor n2 k1 (Tensor n3 k2 v))
-> AbsTensor3 n1 n2 n3 k1 k2 v
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n1 k1
i1,(IndList n2 k1, Tensor n3 k2 v) -> Tensor n2 k1 (Tensor n3 k2 v)
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n2 k1
i2,(IndList n3 k2, v) -> Tensor n3 k2 v
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n3 k2
i3,v
s)))

mkTens4 :: (IndTuple4 n1 n2 n3 n4 k1 k2, v) -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
mkTens4 :: (IndTuple4 n1 n2 n3 n4 k1 k2, v) -> AbsTensor4 n1 n2 n3 n4 k1 k2 v
mkTens4 ((IndList n1 k1
i1,IndList n2 k1
i2,IndList n3 k2
i3,IndList n4 k2
i4),v
s) = (IndList n1 k1, Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v)))
-> AbsTensor4 n1 n2 n3 n4 k1 k2 v
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n1 k1
i1,(IndList n2 k1, Tensor n3 k2 (Tensor n4 k2 v))
-> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v))
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n2 k1
i2,(IndList n3 k2, Tensor n4 k2 v) -> Tensor n3 k2 (Tensor n4 k2 v)
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n3 k2
i3,(IndList n4 k2, v) -> Tensor n4 k2 v
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n4 k2
i4,v
s))))

mkTens5 :: (IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v) -> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
mkTens5 :: (IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
mkTens5 ((IndList n1 k1
i1,IndList n2 k1
i2,IndList n3 k2
i3,IndList n4 k2
i4,IndList n5 k3
i5),v
s) = (IndList n1 k1,
 Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v))))
-> AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n1 k1
i1,(IndList n2 k1, Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))
-> Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n2 k1
i2,(IndList n3 k2, Tensor n4 k2 (Tensor n5 k3 v))
-> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v))
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n3 k2
i3,(IndList n4 k2, Tensor n5 k3 v) -> Tensor n4 k2 (Tensor n5 k3 v)
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n4 k2
i4,(IndList n5 k3, v) -> Tensor n5 k3 v
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n5 k3
i5,v
s)))))

mkTens6 :: (IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v) -> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
mkTens6 :: (IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
mkTens6 ((IndList n1 k1
i1,IndList n2 k1
i2,IndList n3 k2
i3,IndList n4 k2
i4,IndList n5 k3
i5,IndList n6 k3
i6),v
s) = (IndList n1 k1,
 Tensor
   n2
   k1
   (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))))
-> AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n1 k1
i1,(IndList n2 k1,
 Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))
-> Tensor
     n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n2 k1
i2,(IndList n3 k2, Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))
-> Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n3 k2
i3,(IndList n4 k2, Tensor n5 k3 (Tensor n6 k3 v))
-> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n4 k2
i4,(IndList n5 k3, Tensor n6 k3 v) -> Tensor n5 k3 (Tensor n6 k3 v)
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n5 k3
i5,(IndList n6 k3, v) -> Tensor n6 k3 v
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n6 k3
i6,v
s))))))

mkTens7 :: (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
mkTens7 :: (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
mkTens7 ((IndList n1 k1
i1,IndList n2 k1
i2,IndList n3 k2
i3,IndList n4 k2
i4,IndList n5 k3
i5,IndList n6 k3
i6,IndList n7 k4
i7),v
s) = (IndList n1 k1,
 Tensor
   n2
   k1
   (Tensor
      n3
      k2
      (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))))
-> AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n1 k1
i1,(IndList n2 k1,
 Tensor
   n3
   k2
   (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))
-> Tensor
     n2
     k1
     (Tensor
        n3
        k2
        (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n2 k1
i2,(IndList n3 k2,
 Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))
-> Tensor
     n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n3 k2
i3,(IndList n4 k2, Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))
-> Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n4 k2
i4,(IndList n5 k3, Tensor n6 k3 (Tensor n7 k4 v))
-> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n5 k3
i5,(IndList n6 k3, Tensor n7 k4 v) -> Tensor n6 k3 (Tensor n7 k4 v)
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n6 k3
i6,(IndList n7 k4, v) -> Tensor n7 k4 v
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n7 k4
i7,v
s)))))))

mkTens8 :: (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
mkTens8 :: (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
mkTens8 ((IndList n1 k1
i1,IndList n2 k1
i2,IndList n3 k2
i3,IndList n4 k2
i4,IndList n5 k3
i5,IndList n6 k3
i6,IndList n7 k4
i7,IndList n8 k4
i8),v
s) = (IndList n1 k1,
 Tensor
   n2
   k1
   (Tensor
      n3
      k2
      (Tensor
         n4
         k2
         (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))))
-> AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n1 k1
i1,(IndList n2 k1,
 Tensor
   n3
   k2
   (Tensor
      n4
      k2
      (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))
-> Tensor
     n2
     k1
     (Tensor
        n3
        k2
        (Tensor
           n4
           k2
           (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n2 k1
i2,(IndList n3 k2,
 Tensor
   n4
   k2
   (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))
-> Tensor
     n3
     k2
     (Tensor
        n4
        k2
        (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n3 k2
i3,(IndList n4 k2,
 Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))
-> Tensor
     n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n4 k2
i4,(IndList n5 k3, Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))
-> Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n5 k3
i5,(IndList n6 k3, Tensor n7 k4 (Tensor n8 k4 v))
-> Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n6 k3
i6,(IndList n7 k4, Tensor n8 k4 v) -> Tensor n7 k4 (Tensor n8 k4 v)
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n7 k4
i7,(IndList n8 k4, v) -> Tensor n8 k4 v
forall (n :: Nat) k v. (IndList n k, v) -> Tensor n k v
mkTens (IndList n8 k4
i8,v
s))))))))

--convert a tensor to corresponding assocs list

-- | 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.
toListT :: Tensor n k v -> [(IndList n k, v)]
toListT :: Tensor n k v -> [(IndList n k, v)]
toListT (Scalar v
x) = [(IndList n k
forall a. IndList 0 a
Empty, v
x)]
toListT (Tensor TMap k (Tensor n k v)
m) =  ((k, Tensor n k v) -> [(IndList n k, v)])
-> TMap k (Tensor n k v) -> [(IndList n k, v)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(k
i,Tensor n k v
t) -> k -> [(IndList (n - 1) k, v)] -> [(IndList n k, v)]
forall a (n :: Nat) b.
a -> [(IndList (n - 1) a, b)] -> [(IndList n a, b)]
appendF k
i ([(IndList (n - 1) k, v)] -> [(IndList n k, v)])
-> [(IndList (n - 1) k, v)] -> [(IndList n k, v)]
forall a b. (a -> b) -> a -> b
$ Tensor n k v -> [(IndList n k, v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n k v
t) TMap k (Tensor n k v)
m
        where
            appendF :: a -> [(IndList (n - 1) a, b)] -> [(IndList n a, b)]
appendF a
i = ((IndList (n - 1) a, b) -> (IndList n a, b))
-> [(IndList (n - 1) a, b)] -> [(IndList n a, b)]
forall a b. (a -> b) -> [a] -> [b]
map (\(IndList (n - 1) a
l,b
val) -> (a -> IndList (n - 1) a -> IndList n a
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
Append a
i IndList (n - 1) a
l ,b
val))
toListT Tensor n k v
ZeroTensor = []

toListT1 :: AbsTensor1 n1 k1 v -> [(IndTuple1 n1 k1, v)]
toListT1 :: AbsTensor1 n1 k1 v -> [(IndTuple1 n1 k1, v)]
toListT1 = AbsTensor1 n1 k1 v -> [(IndTuple1 n1 k1, v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT

toListT2 :: AbsTensor2 n1 n2 k1 v -> [(IndTuple2 n1 n2 k1, v)]
toListT2 :: AbsTensor2 n1 n2 k1 v -> [(IndTuple2 n1 n2 k1, v)]
toListT2 AbsTensor2 n1 n2 k1 v
t = ((IndList n1 k1, Tensor n2 k1 v) -> [(IndTuple2 n1 n2 k1, v)])
-> [(IndList n1 k1, Tensor n2 k1 v)] -> [(IndTuple2 n1 n2 k1, v)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(IndList n1 k1
x,Tensor n2 k1 v
y) -> IndList n1 k1 -> [(IndList n2 k1, v)] -> [(IndTuple2 n1 n2 k1, v)]
forall a1 b1 b2. a1 -> [(b1, b2)] -> [((a1, b1), b2)]
appendT1 IndList n1 k1
x ([(IndList n2 k1, v)] -> [(IndTuple2 n1 n2 k1, v)])
-> [(IndList n2 k1, v)] -> [(IndTuple2 n1 n2 k1, v)]
forall a b. (a -> b) -> a -> b
$ Tensor n2 k1 v -> [(IndList n2 k1, v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n2 k1 v
y ) ([(IndList n1 k1, Tensor n2 k1 v)] -> [(IndTuple2 n1 n2 k1, v)])
-> [(IndList n1 k1, Tensor n2 k1 v)] -> [(IndTuple2 n1 n2 k1, v)]
forall a b. (a -> b) -> a -> b
$ AbsTensor2 n1 n2 k1 v -> [(IndList n1 k1, Tensor n2 k1 v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT AbsTensor2 n1 n2 k1 v
t

toListT3 :: AbsTensor3 n1 n2 n3 k1 k2 v -> [(IndTuple3 n1 n2 n3 k1 k2, v)]
toListT3 :: AbsTensor3 n1 n2 n3 k1 k2 v -> [(IndTuple3 n1 n2 n3 k1 k2, v)]
toListT3 AbsTensor3 n1 n2 n3 k1 k2 v
t = (((IndList n1 k1, IndList n2 k1), Tensor n3 k2 v)
 -> [(IndTuple3 n1 n2 n3 k1 k2, v)])
-> [((IndList n1 k1, IndList n2 k1), Tensor n3 k2 v)]
-> [(IndTuple3 n1 n2 n3 k1 k2, v)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1)
x,Tensor n3 k2 v
y) -> (IndList n1 k1, IndList n2 k1)
-> [(IndList n3 k2, v)] -> [(IndTuple3 n1 n2 n3 k1 k2, v)]
forall a1 a2 b1 b2. (a1, a2) -> [(b1, b2)] -> [((a1, a2, b1), b2)]
appendT2 (IndList n1 k1, IndList n2 k1)
x ([(IndList n3 k2, v)] -> [(IndTuple3 n1 n2 n3 k1 k2, v)])
-> [(IndList n3 k2, v)] -> [(IndTuple3 n1 n2 n3 k1 k2, v)]
forall a b. (a -> b) -> a -> b
$ Tensor n3 k2 v -> [(IndList n3 k2, v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n3 k2 v
y ) ([((IndList n1 k1, IndList n2 k1), Tensor n3 k2 v)]
 -> [(IndTuple3 n1 n2 n3 k1 k2, v)])
-> [((IndList n1 k1, IndList n2 k1), Tensor n3 k2 v)]
-> [(IndTuple3 n1 n2 n3 k1 k2, v)]
forall a b. (a -> b) -> a -> b
$
             ((IndList n1 k1, Tensor n2 k1 (Tensor n3 k2 v))
 -> [((IndList n1 k1, IndList n2 k1), Tensor n3 k2 v)])
-> [(IndList n1 k1, Tensor n2 k1 (Tensor n3 k2 v))]
-> [((IndList n1 k1, IndList n2 k1), Tensor n3 k2 v)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(IndList n1 k1
x,Tensor n2 k1 (Tensor n3 k2 v)
y) -> IndList n1 k1
-> [(IndList n2 k1, Tensor n3 k2 v)]
-> [((IndList n1 k1, IndList n2 k1), Tensor n3 k2 v)]
forall a1 b1 b2. a1 -> [(b1, b2)] -> [((a1, b1), b2)]
appendT1 IndList n1 k1
x ([(IndList n2 k1, Tensor n3 k2 v)]
 -> [((IndList n1 k1, IndList n2 k1), Tensor n3 k2 v)])
-> [(IndList n2 k1, Tensor n3 k2 v)]
-> [((IndList n1 k1, IndList n2 k1), Tensor n3 k2 v)]
forall a b. (a -> b) -> a -> b
$ Tensor n2 k1 (Tensor n3 k2 v) -> [(IndList n2 k1, Tensor n3 k2 v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n2 k1 (Tensor n3 k2 v)
y ) ([(IndList n1 k1, Tensor n2 k1 (Tensor n3 k2 v))]
 -> [((IndList n1 k1, IndList n2 k1), Tensor n3 k2 v)])
-> [(IndList n1 k1, Tensor n2 k1 (Tensor n3 k2 v))]
-> [((IndList n1 k1, IndList n2 k1), Tensor n3 k2 v)]
forall a b. (a -> b) -> a -> b
$ AbsTensor3 n1 n2 n3 k1 k2 v
-> [(IndList n1 k1, Tensor n2 k1 (Tensor n3 k2 v))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT AbsTensor3 n1 n2 n3 k1 k2 v
t

toListT4 :: AbsTensor4 n1 n2 n3 n4 k1 k2 v -> [(IndTuple4 n1 n2 n3 n4 k1 k2, v)]
toListT4 :: AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> [(IndTuple4 n1 n2 n3 n4 k1 k2, v)]
toListT4 AbsTensor4 n1 n2 n3 n4 k1 k2 v
t = (((IndList n1 k1, IndList n2 k1, IndList n3 k2), Tensor n4 k2 v)
 -> [(IndTuple4 n1 n2 n3 n4 k1 k2, v)])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 v)]
-> [(IndTuple4 n1 n2 n3 n4 k1 k2, v)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1, IndList n3 k2)
x,Tensor n4 k2 v
y) -> (IndList n1 k1, IndList n2 k1, IndList n3 k2)
-> [(IndList n4 k2, v)] -> [(IndTuple4 n1 n2 n3 n4 k1 k2, v)]
forall a1 a2 a3 b1 b2.
(a1, a2, a3) -> [(b1, b2)] -> [((a1, a2, a3, b1), b2)]
appendT3 (IndList n1 k1, IndList n2 k1, IndList n3 k2)
x ([(IndList n4 k2, v)] -> [(IndTuple4 n1 n2 n3 n4 k1 k2, v)])
-> [(IndList n4 k2, v)] -> [(IndTuple4 n1 n2 n3 n4 k1 k2, v)]
forall a b. (a -> b) -> a -> b
$ Tensor n4 k2 v -> [(IndList n4 k2, v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n4 k2 v
y ) ([((IndList n1 k1, IndList n2 k1, IndList n3 k2), Tensor n4 k2 v)]
 -> [(IndTuple4 n1 n2 n3 n4 k1 k2, v)])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 v)]
-> [(IndTuple4 n1 n2 n3 n4 k1 k2, v)]
forall a b. (a -> b) -> a -> b
$
             (((IndList n1 k1, IndList n2 k1), Tensor n3 k2 (Tensor n4 k2 v))
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
      Tensor n4 k2 v)])
-> [((IndList n1 k1, IndList n2 k1),
     Tensor n3 k2 (Tensor n4 k2 v))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 v)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1)
x,Tensor n3 k2 (Tensor n4 k2 v)
y) -> (IndList n1 k1, IndList n2 k1)
-> [(IndList n3 k2, Tensor n4 k2 v)]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 v)]
forall a1 a2 b1 b2. (a1, a2) -> [(b1, b2)] -> [((a1, a2, b1), b2)]
appendT2 (IndList n1 k1, IndList n2 k1)
x ([(IndList n3 k2, Tensor n4 k2 v)]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
      Tensor n4 k2 v)])
-> [(IndList n3 k2, Tensor n4 k2 v)]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 v)]
forall a b. (a -> b) -> a -> b
$ Tensor n3 k2 (Tensor n4 k2 v) -> [(IndList n3 k2, Tensor n4 k2 v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n3 k2 (Tensor n4 k2 v)
y ) ([((IndList n1 k1, IndList n2 k1), Tensor n3 k2 (Tensor n4 k2 v))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
      Tensor n4 k2 v)])
-> [((IndList n1 k1, IndList n2 k1),
     Tensor n3 k2 (Tensor n4 k2 v))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 v)]
forall a b. (a -> b) -> a -> b
$
             ((IndList n1 k1, Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v)))
 -> [((IndList n1 k1, IndList n2 k1),
      Tensor n3 k2 (Tensor n4 k2 v))])
-> [(IndList n1 k1, Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v)))]
-> [((IndList n1 k1, IndList n2 k1),
     Tensor n3 k2 (Tensor n4 k2 v))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(IndList n1 k1
x,Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v))
y) -> IndList n1 k1
-> [(IndList n2 k1, Tensor n3 k2 (Tensor n4 k2 v))]
-> [((IndList n1 k1, IndList n2 k1),
     Tensor n3 k2 (Tensor n4 k2 v))]
forall a1 b1 b2. a1 -> [(b1, b2)] -> [((a1, b1), b2)]
appendT1 IndList n1 k1
x ([(IndList n2 k1, Tensor n3 k2 (Tensor n4 k2 v))]
 -> [((IndList n1 k1, IndList n2 k1),
      Tensor n3 k2 (Tensor n4 k2 v))])
-> [(IndList n2 k1, Tensor n3 k2 (Tensor n4 k2 v))]
-> [((IndList n1 k1, IndList n2 k1),
     Tensor n3 k2 (Tensor n4 k2 v))]
forall a b. (a -> b) -> a -> b
$ Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v))
-> [(IndList n2 k1, Tensor n3 k2 (Tensor n4 k2 v))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v))
y ) ([(IndList n1 k1, Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v)))]
 -> [((IndList n1 k1, IndList n2 k1),
      Tensor n3 k2 (Tensor n4 k2 v))])
-> [(IndList n1 k1, Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v)))]
-> [((IndList n1 k1, IndList n2 k1),
     Tensor n3 k2 (Tensor n4 k2 v))]
forall a b. (a -> b) -> a -> b
$ AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> [(IndList n1 k1, Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 v)))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT AbsTensor4 n1 n2 n3 n4 k1 k2 v
t

toListT5 :: AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)]
toListT5 :: AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)]
toListT5 AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
t = (((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
  Tensor n5 k3 v)
 -> [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 v)]
-> [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2)
x,Tensor n5 k3 v
y) -> (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2)
-> [(IndList n5 k3, v)] -> [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)]
forall a1 a2 a3 a4 b1 b2.
(a1, a2, a3, a4) -> [(b1, b2)] -> [((a1, a2, a3, a4, b1), b2)]
appendT4 (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2)
x ([(IndList n5 k3, v)] -> [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)])
-> [(IndList n5 k3, v)] -> [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)]
forall a b. (a -> b) -> a -> b
$ Tensor n5 k3 v -> [(IndList n5 k3, v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n5 k3 v
y ) ([((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
   Tensor n5 k3 v)]
 -> [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 v)]
-> [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)]
forall a b. (a -> b) -> a -> b
$
             (((IndList n1 k1, IndList n2 k1, IndList n3 k2),
  Tensor n4 k2 (Tensor n5 k3 v))
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
      Tensor n5 k3 v)])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 (Tensor n5 k3 v))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 v)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1, IndList n3 k2)
x,Tensor n4 k2 (Tensor n5 k3 v)
y) -> (IndList n1 k1, IndList n2 k1, IndList n3 k2)
-> [(IndList n4 k2, Tensor n5 k3 v)]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 v)]
forall a1 a2 a3 b1 b2.
(a1, a2, a3) -> [(b1, b2)] -> [((a1, a2, a3, b1), b2)]
appendT3 (IndList n1 k1, IndList n2 k1, IndList n3 k2)
x ([(IndList n4 k2, Tensor n5 k3 v)]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
      Tensor n5 k3 v)])
-> [(IndList n4 k2, Tensor n5 k3 v)]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 v)]
forall a b. (a -> b) -> a -> b
$ Tensor n4 k2 (Tensor n5 k3 v) -> [(IndList n4 k2, Tensor n5 k3 v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n4 k2 (Tensor n5 k3 v)
y ) ([((IndList n1 k1, IndList n2 k1, IndList n3 k2),
   Tensor n4 k2 (Tensor n5 k3 v))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
      Tensor n5 k3 v)])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 (Tensor n5 k3 v))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 v)]
forall a b. (a -> b) -> a -> b
$
             (((IndList n1 k1, IndList n2 k1),
  Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
      Tensor n4 k2 (Tensor n5 k3 v))])
-> [((IndList n1 k1, IndList n2 k1),
     Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 (Tensor n5 k3 v))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1)
x,Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v))
y) -> (IndList n1 k1, IndList n2 k1)
-> [(IndList n3 k2, Tensor n4 k2 (Tensor n5 k3 v))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 (Tensor n5 k3 v))]
forall a1 a2 b1 b2. (a1, a2) -> [(b1, b2)] -> [((a1, a2, b1), b2)]
appendT2 (IndList n1 k1, IndList n2 k1)
x ([(IndList n3 k2, Tensor n4 k2 (Tensor n5 k3 v))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
      Tensor n4 k2 (Tensor n5 k3 v))])
-> [(IndList n3 k2, Tensor n4 k2 (Tensor n5 k3 v))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 (Tensor n5 k3 v))]
forall a b. (a -> b) -> a -> b
$ Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v))
-> [(IndList n3 k2, Tensor n4 k2 (Tensor n5 k3 v))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v))
y ) ([((IndList n1 k1, IndList n2 k1),
   Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
      Tensor n4 k2 (Tensor n5 k3 v))])
-> [((IndList n1 k1, IndList n2 k1),
     Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 (Tensor n5 k3 v))]
forall a b. (a -> b) -> a -> b
$
             ((IndList n1 k1,
  Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v))))
 -> [((IndList n1 k1, IndList n2 k1),
      Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))])
-> [(IndList n1 k1,
     Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v))))]
-> [((IndList n1 k1, IndList n2 k1),
     Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(IndList n1 k1
x,Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))
y) -> IndList n1 k1
-> [(IndList n2 k1, Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))]
-> [((IndList n1 k1, IndList n2 k1),
     Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))]
forall a1 b1 b2. a1 -> [(b1, b2)] -> [((a1, b1), b2)]
appendT1 IndList n1 k1
x ([(IndList n2 k1, Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))]
 -> [((IndList n1 k1, IndList n2 k1),
      Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))])
-> [(IndList n2 k1, Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))]
-> [((IndList n1 k1, IndList n2 k1),
     Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))]
forall a b. (a -> b) -> a -> b
$ Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))
-> [(IndList n2 k1, Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))
y ) ([(IndList n1 k1,
   Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v))))]
 -> [((IndList n1 k1, IndList n2 k1),
      Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))])
-> [(IndList n1 k1,
     Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v))))]
-> [((IndList n1 k1, IndList n2 k1),
     Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v)))]
forall a b. (a -> b) -> a -> b
$ AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> [(IndList n1 k1,
     Tensor n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 v))))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
t

toListT6 :: AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)]
toListT6 :: AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)]
toListT6 AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
t = (((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3),
  Tensor n6 k3 v)
 -> [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     Tensor n6 k3 v)]
-> [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3)
x,Tensor n6 k3 v
y) -> (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3)
-> [(IndList n6 k3, v)]
-> [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)]
forall a1 a2 a3 a4 a5 b1 b2.
(a1, a2, a3, a4, a5)
-> [(b1, b2)] -> [((a1, a2, a3, a4, a5, b1), b2)]
appendT5 (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3)
x ([(IndList n6 k3, v)]
 -> [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)])
-> [(IndList n6 k3, v)]
-> [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)]
forall a b. (a -> b) -> a -> b
$ Tensor n6 k3 v -> [(IndList n6 k3, v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n6 k3 v
y ) ([((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
    IndList n5 k3),
   Tensor n6 k3 v)]
 -> [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     Tensor n6 k3 v)]
-> [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)]
forall a b. (a -> b) -> a -> b
$
             (((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
  Tensor n5 k3 (Tensor n6 k3 v))
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
       IndList n5 k3),
      Tensor n6 k3 v)])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 (Tensor n6 k3 v))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     Tensor n6 k3 v)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2)
x,Tensor n5 k3 (Tensor n6 k3 v)
y) -> (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2)
-> [(IndList n5 k3, Tensor n6 k3 v)]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     Tensor n6 k3 v)]
forall a1 a2 a3 a4 b1 b2.
(a1, a2, a3, a4) -> [(b1, b2)] -> [((a1, a2, a3, a4, b1), b2)]
appendT4 (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2)
x ([(IndList n5 k3, Tensor n6 k3 v)]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
       IndList n5 k3),
      Tensor n6 k3 v)])
-> [(IndList n5 k3, Tensor n6 k3 v)]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     Tensor n6 k3 v)]
forall a b. (a -> b) -> a -> b
$ Tensor n5 k3 (Tensor n6 k3 v) -> [(IndList n5 k3, Tensor n6 k3 v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n5 k3 (Tensor n6 k3 v)
y ) ([((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
   Tensor n5 k3 (Tensor n6 k3 v))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
       IndList n5 k3),
      Tensor n6 k3 v)])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 (Tensor n6 k3 v))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     Tensor n6 k3 v)]
forall a b. (a -> b) -> a -> b
$
             (((IndList n1 k1, IndList n2 k1, IndList n3 k2),
  Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
      Tensor n5 k3 (Tensor n6 k3 v))])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 (Tensor n6 k3 v))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1, IndList n3 k2)
x,Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))
y) -> (IndList n1 k1, IndList n2 k1, IndList n3 k2)
-> [(IndList n4 k2, Tensor n5 k3 (Tensor n6 k3 v))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 (Tensor n6 k3 v))]
forall a1 a2 a3 b1 b2.
(a1, a2, a3) -> [(b1, b2)] -> [((a1, a2, a3, b1), b2)]
appendT3 (IndList n1 k1, IndList n2 k1, IndList n3 k2)
x ([(IndList n4 k2, Tensor n5 k3 (Tensor n6 k3 v))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
      Tensor n5 k3 (Tensor n6 k3 v))])
-> [(IndList n4 k2, Tensor n5 k3 (Tensor n6 k3 v))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 (Tensor n6 k3 v))]
forall a b. (a -> b) -> a -> b
$ Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))
-> [(IndList n4 k2, Tensor n5 k3 (Tensor n6 k3 v))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))
y ) ([((IndList n1 k1, IndList n2 k1, IndList n3 k2),
   Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
      Tensor n5 k3 (Tensor n6 k3 v))])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 (Tensor n6 k3 v))]
forall a b. (a -> b) -> a -> b
$
             (((IndList n1 k1, IndList n2 k1),
  Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
      Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))])
-> [((IndList n1 k1, IndList n2 k1),
     Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1)
x,Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))
y) -> (IndList n1 k1, IndList n2 k1)
-> [(IndList n3 k2, Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))]
forall a1 a2 b1 b2. (a1, a2) -> [(b1, b2)] -> [((a1, a2, b1), b2)]
appendT2 (IndList n1 k1, IndList n2 k1)
x ([(IndList n3 k2, Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
      Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))])
-> [(IndList n3 k2, Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))]
forall a b. (a -> b) -> a -> b
$ Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))
-> [(IndList n3 k2, Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))
y ) ([((IndList n1 k1, IndList n2 k1),
   Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
      Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))])
-> [((IndList n1 k1, IndList n2 k1),
     Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))]
forall a b. (a -> b) -> a -> b
$
             ((IndList n1 k1,
  Tensor
    n2
    k1
    (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))))
 -> [((IndList n1 k1, IndList n2 k1),
      Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))])
-> [(IndList n1 k1,
     Tensor
       n2
       k1
       (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))))]
-> [((IndList n1 k1, IndList n2 k1),
     Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(IndList n1 k1
x,Tensor
  n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))
y) -> IndList n1 k1
-> [(IndList n2 k1,
     Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))]
-> [((IndList n1 k1, IndList n2 k1),
     Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))]
forall a1 b1 b2. a1 -> [(b1, b2)] -> [((a1, b1), b2)]
appendT1 IndList n1 k1
x ([(IndList n2 k1,
   Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))]
 -> [((IndList n1 k1, IndList n2 k1),
      Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))])
-> [(IndList n2 k1,
     Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))]
-> [((IndList n1 k1, IndList n2 k1),
     Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))]
forall a b. (a -> b) -> a -> b
$ Tensor
  n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))
-> [(IndList n2 k1,
     Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor
  n2 k1 (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))
y ) ([(IndList n1 k1,
   Tensor
     n2
     k1
     (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))))]
 -> [((IndList n1 k1, IndList n2 k1),
      Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))])
-> [(IndList n1 k1,
     Tensor
       n2
       k1
       (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))))]
-> [((IndList n1 k1, IndList n2 k1),
     Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v))))]
forall a b. (a -> b) -> a -> b
$ AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> [(IndList n1 k1,
     Tensor
       n2
       k1
       (Tensor n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 v)))))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
t

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)]
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)]
toListT7 AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
t = (((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3),
  Tensor n7 k4 v)
 -> [(IndTuple7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4, v)])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3),
     Tensor n7 k4 v)]
-> [(IndTuple7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4, v)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3)
x,Tensor n7 k4 v
y) -> (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3)
-> [(IndList n7 k4, v)]
-> [(IndTuple7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4, v)]
forall a1 a2 a3 a4 a5 a6 b1 b2.
(a1, a2, a3, a4, a5, a6)
-> [(b1, b2)] -> [((a1, a2, a3, a4, a5, a6, b1), b2)]
appendT6 (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3)
x ([(IndList n7 k4, v)]
 -> [(IndTuple7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4, v)])
-> [(IndList n7 k4, v)]
-> [(IndTuple7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4, v)]
forall a b. (a -> b) -> a -> b
$ Tensor n7 k4 v -> [(IndList n7 k4, v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n7 k4 v
y ) ([((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
    IndList n5 k3, IndList n6 k3),
   Tensor n7 k4 v)]
 -> [(IndTuple7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4, v)])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3),
     Tensor n7 k4 v)]
-> [(IndTuple7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4, v)]
forall a b. (a -> b) -> a -> b
$
             (((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3),
  Tensor n6 k3 (Tensor n7 k4 v))
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
       IndList n5 k3, IndList n6 k3),
      Tensor n7 k4 v)])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     Tensor n6 k3 (Tensor n7 k4 v))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3),
     Tensor n7 k4 v)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3)
x,Tensor n6 k3 (Tensor n7 k4 v)
y) -> (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3)
-> [(IndList n6 k3, Tensor n7 k4 v)]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3),
     Tensor n7 k4 v)]
forall a1 a2 a3 a4 a5 b1 b2.
(a1, a2, a3, a4, a5)
-> [(b1, b2)] -> [((a1, a2, a3, a4, a5, b1), b2)]
appendT5 (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3)
x ([(IndList n6 k3, Tensor n7 k4 v)]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
       IndList n5 k3, IndList n6 k3),
      Tensor n7 k4 v)])
-> [(IndList n6 k3, Tensor n7 k4 v)]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3),
     Tensor n7 k4 v)]
forall a b. (a -> b) -> a -> b
$ Tensor n6 k3 (Tensor n7 k4 v) -> [(IndList n6 k3, Tensor n7 k4 v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n6 k3 (Tensor n7 k4 v)
y ) ([((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
    IndList n5 k3),
   Tensor n6 k3 (Tensor n7 k4 v))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
       IndList n5 k3, IndList n6 k3),
      Tensor n7 k4 v)])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     Tensor n6 k3 (Tensor n7 k4 v))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3),
     Tensor n7 k4 v)]
forall a b. (a -> b) -> a -> b
$
             (((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
  Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
       IndList n5 k3),
      Tensor n6 k3 (Tensor n7 k4 v))])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     Tensor n6 k3 (Tensor n7 k4 v))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2)
x,Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))
y) -> (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2)
-> [(IndList n5 k3, Tensor n6 k3 (Tensor n7 k4 v))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     Tensor n6 k3 (Tensor n7 k4 v))]
forall a1 a2 a3 a4 b1 b2.
(a1, a2, a3, a4) -> [(b1, b2)] -> [((a1, a2, a3, a4, b1), b2)]
appendT4 (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2)
x ([(IndList n5 k3, Tensor n6 k3 (Tensor n7 k4 v))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
       IndList n5 k3),
      Tensor n6 k3 (Tensor n7 k4 v))])
-> [(IndList n5 k3, Tensor n6 k3 (Tensor n7 k4 v))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     Tensor n6 k3 (Tensor n7 k4 v))]
forall a b. (a -> b) -> a -> b
$ Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))
-> [(IndList n5 k3, Tensor n6 k3 (Tensor n7 k4 v))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))
y ) ([((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
   Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
       IndList n5 k3),
      Tensor n6 k3 (Tensor n7 k4 v))])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     Tensor n6 k3 (Tensor n7 k4 v))]
forall a b. (a -> b) -> a -> b
$
             (((IndList n1 k1, IndList n2 k1, IndList n3 k2),
  Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
      Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1, IndList n3 k2)
x,Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))
y) -> (IndList n1 k1, IndList n2 k1, IndList n3 k2)
-> [(IndList n4 k2, Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))]
forall a1 a2 a3 b1 b2.
(a1, a2, a3) -> [(b1, b2)] -> [((a1, a2, a3, b1), b2)]
appendT3 (IndList n1 k1, IndList n2 k1, IndList n3 k2)
x ([(IndList n4 k2, Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
      Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))])
-> [(IndList n4 k2, Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))]
forall a b. (a -> b) -> a -> b
$ Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))
-> [(IndList n4 k2, Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))
y ) ([((IndList n1 k1, IndList n2 k1, IndList n3 k2),
   Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
      Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))]
forall a b. (a -> b) -> a -> b
$
             (((IndList n1 k1, IndList n2 k1),
  Tensor
    n3
    k2
    (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
      Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))])
-> [((IndList n1 k1, IndList n2 k1),
     Tensor
       n3
       k2
       (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1)
x,Tensor
  n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))
y) -> (IndList n1 k1, IndList n2 k1)
-> [(IndList n3 k2,
     Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))]
forall a1 a2 b1 b2. (a1, a2) -> [(b1, b2)] -> [((a1, a2, b1), b2)]
appendT2 (IndList n1 k1, IndList n2 k1)
x ([(IndList n3 k2,
   Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
      Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))])
-> [(IndList n3 k2,
     Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))]
forall a b. (a -> b) -> a -> b
$ Tensor
  n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))
-> [(IndList n3 k2,
     Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor
  n3 k2 (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))
y ) ([((IndList n1 k1, IndList n2 k1),
   Tensor
     n3
     k2
     (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
      Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))])
-> [((IndList n1 k1, IndList n2 k1),
     Tensor
       n3
       k2
       (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))]
forall a b. (a -> b) -> a -> b
$
             ((IndList n1 k1,
  Tensor
    n2
    k1
    (Tensor
       n3
       k2
       (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))))
 -> [((IndList n1 k1, IndList n2 k1),
      Tensor
        n3
        k2
        (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))])
-> [(IndList n1 k1,
     Tensor
       n2
       k1
       (Tensor
          n3
          k2
          (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))))]
-> [((IndList n1 k1, IndList n2 k1),
     Tensor
       n3
       k2
       (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(IndList n1 k1
x,Tensor
  n2
  k1
  (Tensor
     n3
     k2
     (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))
y) -> IndList n1 k1
-> [(IndList n2 k1,
     Tensor
       n3
       k2
       (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))]
-> [((IndList n1 k1, IndList n2 k1),
     Tensor
       n3
       k2
       (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))]
forall a1 b1 b2. a1 -> [(b1, b2)] -> [((a1, b1), b2)]
appendT1 IndList n1 k1
x ([(IndList n2 k1,
   Tensor
     n3
     k2
     (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))]
 -> [((IndList n1 k1, IndList n2 k1),
      Tensor
        n3
        k2
        (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))])
-> [(IndList n2 k1,
     Tensor
       n3
       k2
       (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))]
-> [((IndList n1 k1, IndList n2 k1),
     Tensor
       n3
       k2
       (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))]
forall a b. (a -> b) -> a -> b
$ Tensor
  n2
  k1
  (Tensor
     n3
     k2
     (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))
-> [(IndList n2 k1,
     Tensor
       n3
       k2
       (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor
  n2
  k1
  (Tensor
     n3
     k2
     (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))
y ) ([(IndList n1 k1,
   Tensor
     n2
     k1
     (Tensor
        n3
        k2
        (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))))]
 -> [((IndList n1 k1, IndList n2 k1),
      Tensor
        n3
        k2
        (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))])
-> [(IndList n1 k1,
     Tensor
       n2
       k1
       (Tensor
          n3
          k2
          (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))))]
-> [((IndList n1 k1, IndList n2 k1),
     Tensor
       n3
       k2
       (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v)))))]
forall a b. (a -> b) -> a -> b
$ AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
-> [(IndList n1 k1,
     Tensor
       n2
       k1
       (Tensor
          n3
          k2
          (Tensor n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 v))))))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
t

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)]
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)]
toListT8 AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
t = (((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3, IndList n7 k4),
  Tensor n8 k4 v)
 -> [(IndTuple8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4, v)])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3, IndList n7 k4),
     Tensor n8 k4 v)]
-> [(IndTuple8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4, v)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3, IndList n7 k4)
x,Tensor n8 k4 v
y) -> (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3, IndList n7 k4)
-> [(IndList n8 k4, v)]
-> [(IndTuple8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4, v)]
forall a1 a2 a3 a4 a5 a6 a7 b1 b2.
(a1, a2, a3, a4, a5, a6, a7)
-> [(b1, b2)] -> [((a1, a2, a3, a4, a5, a6, a7, b1), b2)]
appendT7 (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3, IndList n7 k4)
x ([(IndList n8 k4, v)]
 -> [(IndTuple8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4, v)])
-> [(IndList n8 k4, v)]
-> [(IndTuple8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4, v)]
forall a b. (a -> b) -> a -> b
$ Tensor n8 k4 v -> [(IndList n8 k4, v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n8 k4 v
y ) ([((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
    IndList n5 k3, IndList n6 k3, IndList n7 k4),
   Tensor n8 k4 v)]
 -> [(IndTuple8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4, v)])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3, IndList n7 k4),
     Tensor n8 k4 v)]
-> [(IndTuple8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4, v)]
forall a b. (a -> b) -> a -> b
$
             (((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3),
  Tensor n7 k4 (Tensor n8 k4 v))
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
       IndList n5 k3, IndList n6 k3, IndList n7 k4),
      Tensor n8 k4 v)])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3),
     Tensor n7 k4 (Tensor n8 k4 v))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3, IndList n7 k4),
     Tensor n8 k4 v)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3)
x,Tensor n7 k4 (Tensor n8 k4 v)
y) -> (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3)
-> [(IndList n7 k4, Tensor n8 k4 v)]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3, IndList n7 k4),
     Tensor n8 k4 v)]
forall a1 a2 a3 a4 a5 a6 b1 b2.
(a1, a2, a3, a4, a5, a6)
-> [(b1, b2)] -> [((a1, a2, a3, a4, a5, a6, b1), b2)]
appendT6 (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3)
x ([(IndList n7 k4, Tensor n8 k4 v)]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
       IndList n5 k3, IndList n6 k3, IndList n7 k4),
      Tensor n8 k4 v)])
-> [(IndList n7 k4, Tensor n8 k4 v)]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3, IndList n7 k4),
     Tensor n8 k4 v)]
forall a b. (a -> b) -> a -> b
$ Tensor n7 k4 (Tensor n8 k4 v) -> [(IndList n7 k4, Tensor n8 k4 v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n7 k4 (Tensor n8 k4 v)
y ) ([((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
    IndList n5 k3, IndList n6 k3),
   Tensor n7 k4 (Tensor n8 k4 v))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
       IndList n5 k3, IndList n6 k3, IndList n7 k4),
      Tensor n8 k4 v)])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3),
     Tensor n7 k4 (Tensor n8 k4 v))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3, IndList n7 k4),
     Tensor n8 k4 v)]
forall a b. (a -> b) -> a -> b
$
             (((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3),
  Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
       IndList n5 k3, IndList n6 k3),
      Tensor n7 k4 (Tensor n8 k4 v))])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3),
     Tensor n7 k4 (Tensor n8 k4 v))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3)
x,Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))
y) -> (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3)
-> [(IndList n6 k3, Tensor n7 k4 (Tensor n8 k4 v))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3),
     Tensor n7 k4 (Tensor n8 k4 v))]
forall a1 a2 a3 a4 a5 b1 b2.
(a1, a2, a3, a4, a5)
-> [(b1, b2)] -> [((a1, a2, a3, a4, a5, b1), b2)]
appendT5 (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3)
x ([(IndList n6 k3, Tensor n7 k4 (Tensor n8 k4 v))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
       IndList n5 k3, IndList n6 k3),
      Tensor n7 k4 (Tensor n8 k4 v))])
-> [(IndList n6 k3, Tensor n7 k4 (Tensor n8 k4 v))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3),
     Tensor n7 k4 (Tensor n8 k4 v))]
forall a b. (a -> b) -> a -> b
$ Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))
-> [(IndList n6 k3, Tensor n7 k4 (Tensor n8 k4 v))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))
y ) ([((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
    IndList n5 k3),
   Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
       IndList n5 k3, IndList n6 k3),
      Tensor n7 k4 (Tensor n8 k4 v))])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3),
     Tensor n7 k4 (Tensor n8 k4 v))]
forall a b. (a -> b) -> a -> b
$
             (((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
  Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
       IndList n5 k3),
      Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2)
x,Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))
y) -> (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2)
-> [(IndList n5 k3, Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))]
forall a1 a2 a3 a4 b1 b2.
(a1, a2, a3, a4) -> [(b1, b2)] -> [((a1, a2, a3, a4, b1), b2)]
appendT4 (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2)
x ([(IndList n5 k3, Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
       IndList n5 k3),
      Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))])
-> [(IndList n5 k3, Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))]
forall a b. (a -> b) -> a -> b
$ Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))
-> [(IndList n5 k3, Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))
y ) ([((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
   Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
       IndList n5 k3),
      Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))]
forall a b. (a -> b) -> a -> b
$
             (((IndList n1 k1, IndList n2 k1, IndList n3 k2),
  Tensor
    n4
    k2
    (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
      Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor
       n4
       k2
       (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1, IndList n3 k2)
x,Tensor
  n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))
y) -> (IndList n1 k1, IndList n2 k1, IndList n3 k2)
-> [(IndList n4 k2,
     Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))]
forall a1 a2 a3 b1 b2.
(a1, a2, a3) -> [(b1, b2)] -> [((a1, a2, a3, b1), b2)]
appendT3 (IndList n1 k1, IndList n2 k1, IndList n3 k2)
x ([(IndList n4 k2,
   Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
      Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))])
-> [(IndList n4 k2,
     Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))]
forall a b. (a -> b) -> a -> b
$ Tensor
  n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))
-> [(IndList n4 k2,
     Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor
  n4 k2 (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))
y ) ([((IndList n1 k1, IndList n2 k1, IndList n3 k2),
   Tensor
     n4
     k2
     (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
      Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))])
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor
       n4
       k2
       (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))]
forall a b. (a -> b) -> a -> b
$
             (((IndList n1 k1, IndList n2 k1),
  Tensor
    n3
    k2
    (Tensor
       n4
       k2
       (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
      Tensor
        n4
        k2
        (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))])
-> [((IndList n1 k1, IndList n2 k1),
     Tensor
       n3
       k2
       (Tensor
          n4
          k2
          (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor
       n4
       k2
       (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\((IndList n1 k1, IndList n2 k1)
x,Tensor
  n3
  k2
  (Tensor
     n4
     k2
     (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))
y) -> (IndList n1 k1, IndList n2 k1)
-> [(IndList n3 k2,
     Tensor
       n4
       k2
       (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor
       n4
       k2
       (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))]
forall a1 a2 b1 b2. (a1, a2) -> [(b1, b2)] -> [((a1, a2, b1), b2)]
appendT2 (IndList n1 k1, IndList n2 k1)
x ([(IndList n3 k2,
   Tensor
     n4
     k2
     (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
      Tensor
        n4
        k2
        (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))])
-> [(IndList n3 k2,
     Tensor
       n4
       k2
       (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor
       n4
       k2
       (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))]
forall a b. (a -> b) -> a -> b
$ Tensor
  n3
  k2
  (Tensor
     n4
     k2
     (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))
-> [(IndList n3 k2,
     Tensor
       n4
       k2
       (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor
  n3
  k2
  (Tensor
     n4
     k2
     (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))
y ) ([((IndList n1 k1, IndList n2 k1),
   Tensor
     n3
     k2
     (Tensor
        n4
        k2
        (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))]
 -> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
      Tensor
        n4
        k2
        (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))])
-> [((IndList n1 k1, IndList n2 k1),
     Tensor
       n3
       k2
       (Tensor
          n4
          k2
          (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))]
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2),
     Tensor
       n4
       k2
       (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))]
forall a b. (a -> b) -> a -> b
$
             ((IndList n1 k1,
  Tensor
    n2
    k1
    (Tensor
       n3
       k2
       (Tensor
          n4
          k2
          (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))))
 -> [((IndList n1 k1, IndList n2 k1),
      Tensor
        n3
        k2
        (Tensor
           n4
           k2
           (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))])
-> [(IndList n1 k1,
     Tensor
       n2
       k1
       (Tensor
          n3
          k2
          (Tensor
             n4
             k2
             (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))))]
-> [((IndList n1 k1, IndList n2 k1),
     Tensor
       n3
       k2
       (Tensor
          n4
          k2
          (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(IndList n1 k1
x,Tensor
  n2
  k1
  (Tensor
     n3
     k2
     (Tensor
        n4
        k2
        (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))
y) -> IndList n1 k1
-> [(IndList n2 k1,
     Tensor
       n3
       k2
       (Tensor
          n4
          k2
          (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))]
-> [((IndList n1 k1, IndList n2 k1),
     Tensor
       n3
       k2
       (Tensor
          n4
          k2
          (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))]
forall a1 b1 b2. a1 -> [(b1, b2)] -> [((a1, b1), b2)]
appendT1 IndList n1 k1
x ([(IndList n2 k1,
   Tensor
     n3
     k2
     (Tensor
        n4
        k2
        (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))]
 -> [((IndList n1 k1, IndList n2 k1),
      Tensor
        n3
        k2
        (Tensor
           n4
           k2
           (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))])
-> [(IndList n2 k1,
     Tensor
       n3
       k2
       (Tensor
          n4
          k2
          (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))]
-> [((IndList n1 k1, IndList n2 k1),
     Tensor
       n3
       k2
       (Tensor
          n4
          k2
          (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))]
forall a b. (a -> b) -> a -> b
$ Tensor
  n2
  k1
  (Tensor
     n3
     k2
     (Tensor
        n4
        k2
        (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))
-> [(IndList n2 k1,
     Tensor
       n3
       k2
       (Tensor
          n4
          k2
          (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor
  n2
  k1
  (Tensor
     n3
     k2
     (Tensor
        n4
        k2
        (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))
y ) ([(IndList n1 k1,
   Tensor
     n2
     k1
     (Tensor
        n3
        k2
        (Tensor
           n4
           k2
           (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))))]
 -> [((IndList n1 k1, IndList n2 k1),
      Tensor
        n3
        k2
        (Tensor
           n4
           k2
           (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))])
-> [(IndList n1 k1,
     Tensor
       n2
       k1
       (Tensor
          n3
          k2
          (Tensor
             n4
             k2
             (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))))]
-> [((IndList n1 k1, IndList n2 k1),
     Tensor
       n3
       k2
       (Tensor
          n4
          k2
          (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v))))))]
forall a b. (a -> b) -> a -> b
$ AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
-> [(IndList n1 k1,
     Tensor
       n2
       k1
       (Tensor
          n3
          k2
          (Tensor
             n4
             k2
             (Tensor n5 k3 (Tensor n6 k3 (Tensor n7 k4 (Tensor n8 k4 v)))))))]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
t

appendT1 :: a1 -> [(b1, b2)] -> [((a1, b1), b2)]
appendT1 :: a1 -> [(b1, b2)] -> [((a1, b1), b2)]
appendT1 a1
i = ((b1, b2) -> ((a1, b1), b2)) -> [(b1, b2)] -> [((a1, b1), b2)]
forall a b. (a -> b) -> [a] -> [b]
map (\(b1
x,b2
y) -> ((a1
i,b1
x),b2
y))

appendT2 :: (a1, a2) -> [(b1, b2)] -> [((a1, a2, b1), b2)]
appendT2 :: (a1, a2) -> [(b1, b2)] -> [((a1, a2, b1), b2)]
appendT2 (a1
i1,a2
i2) = ((b1, b2) -> ((a1, a2, b1), b2))
-> [(b1, b2)] -> [((a1, a2, b1), b2)]
forall a b. (a -> b) -> [a] -> [b]
map (\(b1
x,b2
y) -> ((a1
i1,a2
i2,b1
x),b2
y))

appendT3 :: (a1, a2, a3) -> [(b1, b2)] -> [((a1, a2, a3, b1), b2)]
appendT3 :: (a1, a2, a3) -> [(b1, b2)] -> [((a1, a2, a3, b1), b2)]
appendT3 (a1
i1,a2
i2,a3
i3) = ((b1, b2) -> ((a1, a2, a3, b1), b2))
-> [(b1, b2)] -> [((a1, a2, a3, b1), b2)]
forall a b. (a -> b) -> [a] -> [b]
map (\(b1
x,b2
y) -> ((a1
i1,a2
i2,a3
i3,b1
x),b2
y))

appendT4 :: (a1, a2, a3, a4) -> [(b1, b2)] -> [((a1, a2, a3, a4, b1), b2)]
appendT4 :: (a1, a2, a3, a4) -> [(b1, b2)] -> [((a1, a2, a3, a4, b1), b2)]
appendT4 (a1
i1,a2
i2,a3
i3,a4
i4) = ((b1, b2) -> ((a1, a2, a3, a4, b1), b2))
-> [(b1, b2)] -> [((a1, a2, a3, a4, b1), b2)]
forall a b. (a -> b) -> [a] -> [b]
map (\(b1
x,b2
y) -> ((a1
i1,a2
i2,a3
i3,a4
i4,b1
x),b2
y))

appendT5 :: (a1, a2, a3, a4, a5) -> [(b1, b2)] -> [((a1, a2, a3, a4, a5, b1), b2)]
appendT5 :: (a1, a2, a3, a4, a5)
-> [(b1, b2)] -> [((a1, a2, a3, a4, a5, b1), b2)]
appendT5 (a1
i1,a2
i2,a3
i3,a4
i4,a5
i5) = ((b1, b2) -> ((a1, a2, a3, a4, a5, b1), b2))
-> [(b1, b2)] -> [((a1, a2, a3, a4, a5, b1), b2)]
forall a b. (a -> b) -> [a] -> [b]
map (\(b1
x,b2
y) -> ((a1
i1,a2
i2,a3
i3,a4
i4,a5
i5,b1
x),b2
y))

appendT6 :: (a1, a2, a3, a4, a5, a6) -> [(b1, b2)] -> [((a1, a2, a3, a4, a5, a6, b1), b2)]
appendT6 :: (a1, a2, a3, a4, a5, a6)
-> [(b1, b2)] -> [((a1, a2, a3, a4, a5, a6, b1), b2)]
appendT6 (a1
i1,a2
i2,a3
i3,a4
i4,a5
i5,a6
i6) = ((b1, b2) -> ((a1, a2, a3, a4, a5, a6, b1), b2))
-> [(b1, b2)] -> [((a1, a2, a3, a4, a5, a6, b1), b2)]
forall a b. (a -> b) -> [a] -> [b]
map (\(b1
x,b2
y) -> ((a1
i1,a2
i2,a3
i3,a4
i4,a5
i5,a6
i6,b1
x),b2
y))

appendT7 :: (a1, a2, a3, a4, a5, a6, a7) -> [(b1, b2)] -> [((a1, a2, a3, a4, a5, a6, a7, b1), b2)]
appendT7 :: (a1, a2, a3, a4, a5, a6, a7)
-> [(b1, b2)] -> [((a1, a2, a3, a4, a5, a6, a7, b1), b2)]
appendT7 (a1
i1,a2
i2,a3
i3,a4
i4,a5
i5,a6
i6,a7
i7) = ((b1, b2) -> ((a1, a2, a3, a4, a5, a6, a7, b1), b2))
-> [(b1, b2)] -> [((a1, a2, a3, a4, a5, a6, a7, b1), b2)]
forall a b. (a -> b) -> [a] -> [b]
map (\(b1
x,b2
y) -> ((a1
i1,a2
i2,a3
i3,a4
i4,a5
i5,a6
i6,a7
i7,b1
x),b2
y))

-- | This function converts a given @'Tensor'@ to a non-typed index tuple list.
toListT' :: (TIndex k, TAdd v) => Tensor n k v -> [([Int],v)]
toListT' :: Tensor n k v -> [([Int], v)]
toListT' Tensor n k v
t = (([Int], v) -> Bool) -> [([Int], v)] -> [([Int], v)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (([Int], v) -> Bool) -> ([Int], v) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v -> Bool
forall a. TAdd a => a -> Bool
scaleZero (v -> Bool) -> (([Int], v) -> v) -> ([Int], v) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], v) -> v
forall a b. (a, b) -> b
snd) ([([Int], v)] -> [([Int], v)]) -> [([Int], v)] -> [([Int], v)]
forall a b. (a -> b) -> a -> b
$ ((IndList n k, v) -> ([Int], v))
-> [(IndList n k, v)] -> [([Int], v)]
forall a b. (a -> b) -> [a] -> [b]
map (\(IndList n k
x,v
y) -> (IndList n k -> [Int]
forall a (t :: * -> *). (Enum a, Foldable t) => t a -> [Int]
showInd IndList n k
x, v
y)) [(IndList n k, v)]
l
        where
            l :: [(IndList n k, v)]
l = Tensor n k v -> [(IndList n k, v)]
forall (n :: Nat) k v. Tensor n k v -> [(IndList n k, v)]
toListT Tensor n k v
t
            showInd :: t a -> [Int]
showInd t a
i1 = (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum ([a] -> [Int]) -> [a] -> [Int]
forall a b. (a -> b) -> a -> b
$ t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i1

toListT1' :: (TIndex k1, TAdd v) => AbsTensor1 n1 k1 v -> [([Int],v)]
toListT1' :: AbsTensor1 n1 k1 v -> [([Int], v)]
toListT1' = AbsTensor1 n1 k1 v -> [([Int], v)]
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> [([Int], v)]
toListT'

toListT2' :: (TIndex k1, TAdd v) => AbsTensor2 n1 n2 k1 v -> [(([Int], [Int]), v)]
toListT2' :: AbsTensor2 n1 n2 k1 v -> [(([Int], [Int]), v)]
toListT2' AbsTensor2 n1 n2 k1 v
t = ((([Int], [Int]), v) -> Bool)
-> [(([Int], [Int]), v)] -> [(([Int], [Int]), v)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> ((([Int], [Int]), v) -> Bool) -> (([Int], [Int]), v) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v -> Bool
forall a. TAdd a => a -> Bool
scaleZero (v -> Bool)
-> ((([Int], [Int]), v) -> v) -> (([Int], [Int]), v) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (([Int], [Int]), v) -> v
forall a b. (a, b) -> b
snd) ([(([Int], [Int]), v)] -> [(([Int], [Int]), v)])
-> [(([Int], [Int]), v)] -> [(([Int], [Int]), v)]
forall a b. (a -> b) -> a -> b
$ (((IndList n1 k1, IndList n2 k1), v) -> (([Int], [Int]), v))
-> [((IndList n1 k1, IndList n2 k1), v)] -> [(([Int], [Int]), v)]
forall a b. (a -> b) -> [a] -> [b]
map (\((IndList n1 k1, IndList n2 k1)
x,v
y) -> ((IndList n1 k1, IndList n2 k1) -> ([Int], [Int])
forall a a (t :: * -> *) (t :: * -> *).
(Enum a, Enum a, Foldable t, Foldable t) =>
(t a, t a) -> ([Int], [Int])
showInd (IndList n1 k1, IndList n2 k1)
x, v
y)) [((IndList n1 k1, IndList n2 k1), v)]
l
        where
            l :: [((IndList n1 k1, IndList n2 k1), v)]
l = AbsTensor2 n1 n2 k1 v -> [((IndList n1 k1, IndList n2 k1), v)]
forall (n1 :: Nat) (n2 :: Nat) k1 v.
AbsTensor2 n1 n2 k1 v -> [(IndTuple2 n1 n2 k1, v)]
toListT2 AbsTensor2 n1 n2 k1 v
t
            showInd :: (t a, t a) -> ([Int], [Int])
showInd (t a
i1,t a
i2) = ((a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i1), (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i2))

toListT3' :: (TIndex k1, TIndex k2, TAdd v) => AbsTensor3 n1 n2 n3 k1 k2 v -> [(([Int], [Int], [Int]),v)]
toListT3' :: AbsTensor3 n1 n2 n3 k1 k2 v -> [(([Int], [Int], [Int]), v)]
toListT3' AbsTensor3 n1 n2 n3 k1 k2 v
t = ((([Int], [Int], [Int]), v) -> Bool)
-> [(([Int], [Int], [Int]), v)] -> [(([Int], [Int], [Int]), v)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> ((([Int], [Int], [Int]), v) -> Bool)
-> (([Int], [Int], [Int]), v)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v -> Bool
forall a. TAdd a => a -> Bool
scaleZero (v -> Bool)
-> ((([Int], [Int], [Int]), v) -> v)
-> (([Int], [Int], [Int]), v)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (([Int], [Int], [Int]), v) -> v
forall a b. (a, b) -> b
snd) ([(([Int], [Int], [Int]), v)] -> [(([Int], [Int], [Int]), v)])
-> [(([Int], [Int], [Int]), v)] -> [(([Int], [Int], [Int]), v)]
forall a b. (a -> b) -> a -> b
$ (((IndList n1 k1, IndList n2 k1, IndList n3 k2), v)
 -> (([Int], [Int], [Int]), v))
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2), v)]
-> [(([Int], [Int], [Int]), v)]
forall a b. (a -> b) -> [a] -> [b]
map (\((IndList n1 k1, IndList n2 k1, IndList n3 k2)
x,v
y) -> ((IndList n1 k1, IndList n2 k1, IndList n3 k2)
-> ([Int], [Int], [Int])
forall a a a (t :: * -> *) (t :: * -> *) (t :: * -> *).
(Enum a, Enum a, Enum a, Foldable t, Foldable t, Foldable t) =>
(t a, t a, t a) -> ([Int], [Int], [Int])
showInd (IndList n1 k1, IndList n2 k1, IndList n3 k2)
x, v
y)) [((IndList n1 k1, IndList n2 k1, IndList n3 k2), v)]
l
        where
            l :: [((IndList n1 k1, IndList n2 k1, IndList n3 k2), v)]
l = AbsTensor3 n1 n2 n3 k1 k2 v
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2), v)]
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2 v.
AbsTensor3 n1 n2 n3 k1 k2 v -> [(IndTuple3 n1 n2 n3 k1 k2, v)]
toListT3 AbsTensor3 n1 n2 n3 k1 k2 v
t
            showInd :: (t a, t a, t a) -> ([Int], [Int], [Int])
showInd (t a
i1,t a
i2,t a
i3) = ((a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i1), (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i2),
                                 (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i3))

toListT4' :: (TIndex k1, TIndex k2, TAdd v) => AbsTensor4 n1 n2 n3 n4 k1 k2 v -> [(([Int], [Int], [Int], [Int]),v)]
toListT4' :: AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> [(([Int], [Int], [Int], [Int]), v)]
toListT4' AbsTensor4 n1 n2 n3 n4 k1 k2 v
t = ((([Int], [Int], [Int], [Int]), v) -> Bool)
-> [(([Int], [Int], [Int], [Int]), v)]
-> [(([Int], [Int], [Int], [Int]), v)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> ((([Int], [Int], [Int], [Int]), v) -> Bool)
-> (([Int], [Int], [Int], [Int]), v)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v -> Bool
forall a. TAdd a => a -> Bool
scaleZero (v -> Bool)
-> ((([Int], [Int], [Int], [Int]), v) -> v)
-> (([Int], [Int], [Int], [Int]), v)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (([Int], [Int], [Int], [Int]), v) -> v
forall a b. (a, b) -> b
snd) ([(([Int], [Int], [Int], [Int]), v)]
 -> [(([Int], [Int], [Int], [Int]), v)])
-> [(([Int], [Int], [Int], [Int]), v)]
-> [(([Int], [Int], [Int], [Int]), v)]
forall a b. (a -> b) -> a -> b
$ (((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2), v)
 -> (([Int], [Int], [Int], [Int]), v))
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     v)]
-> [(([Int], [Int], [Int], [Int]), v)]
forall a b. (a -> b) -> [a] -> [b]
map (\((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2)
x,v
y) -> ((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2)
-> ([Int], [Int], [Int], [Int])
forall a a a a (t :: * -> *) (t :: * -> *) (t :: * -> *)
       (t :: * -> *).
(Enum a, Enum a, Enum a, Enum a, Foldable t, Foldable t,
 Foldable t, Foldable t) =>
(t a, t a, t a, t a) -> ([Int], [Int], [Int], [Int])
showInd (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2)
x, v
y)) [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2), v)]
l
        where
            l :: [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2), v)]
l = AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     v)]
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2 v.
AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> [(IndTuple4 n1 n2 n3 n4 k1 k2, v)]
toListT4 AbsTensor4 n1 n2 n3 n4 k1 k2 v
t
            showInd :: (t a, t a, t a, t a) -> ([Int], [Int], [Int], [Int])
showInd (t a
i1,t a
i2,t a
i3,t a
i4) = ((a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i1), (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i2),
                                    (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i3), (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i4))

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)]
toListT5' :: AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> [(([Int], [Int], [Int], [Int], [Int]), v)]
toListT5' AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
t = ((([Int], [Int], [Int], [Int], [Int]), v) -> Bool)
-> [(([Int], [Int], [Int], [Int], [Int]), v)]
-> [(([Int], [Int], [Int], [Int], [Int]), v)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> ((([Int], [Int], [Int], [Int], [Int]), v) -> Bool)
-> (([Int], [Int], [Int], [Int], [Int]), v)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v -> Bool
forall a. TAdd a => a -> Bool
scaleZero (v -> Bool)
-> ((([Int], [Int], [Int], [Int], [Int]), v) -> v)
-> (([Int], [Int], [Int], [Int], [Int]), v)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (([Int], [Int], [Int], [Int], [Int]), v) -> v
forall a b. (a, b) -> b
snd) ([(([Int], [Int], [Int], [Int], [Int]), v)]
 -> [(([Int], [Int], [Int], [Int], [Int]), v)])
-> [(([Int], [Int], [Int], [Int], [Int]), v)]
-> [(([Int], [Int], [Int], [Int], [Int]), v)]
forall a b. (a -> b) -> a -> b
$ (((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3),
  v)
 -> (([Int], [Int], [Int], [Int], [Int]), v))
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     v)]
-> [(([Int], [Int], [Int], [Int], [Int]), v)]
forall a b. (a -> b) -> [a] -> [b]
map (\((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3)
x,v
y) -> ((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3)
-> ([Int], [Int], [Int], [Int], [Int])
forall a a a a a (t :: * -> *) (t :: * -> *) (t :: * -> *)
       (t :: * -> *) (t :: * -> *).
(Enum a, Enum a, Enum a, Enum a, Enum a, Foldable t, Foldable t,
 Foldable t, Foldable t, Foldable t) =>
(t a, t a, t a, t a, t a) -> ([Int], [Int], [Int], [Int], [Int])
showInd (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3)
x, v
y)) [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3),
  v)]
l
        where
            l :: [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3),
  v)]
l = AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     v)]
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       k1 k2 k3 v.
AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)]
toListT5 AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
t
            showInd :: (t a, t a, t a, t a, t a) -> ([Int], [Int], [Int], [Int], [Int])
showInd (t a
i1,t a
i2,t a
i3,t a
i4,t a
i5) = ((a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i1), (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i2),
                                    (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i3), (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i4),
                                    (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i5))

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)]
toListT6' :: AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> [(([Int], [Int], [Int], [Int], [Int], [Int]), v)]
toListT6' AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
t = ((([Int], [Int], [Int], [Int], [Int], [Int]), v) -> Bool)
-> [(([Int], [Int], [Int], [Int], [Int], [Int]), v)]
-> [(([Int], [Int], [Int], [Int], [Int], [Int]), v)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> ((([Int], [Int], [Int], [Int], [Int], [Int]), v) -> Bool)
-> (([Int], [Int], [Int], [Int], [Int], [Int]), v)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v -> Bool
forall a. TAdd a => a -> Bool
scaleZero (v -> Bool)
-> ((([Int], [Int], [Int], [Int], [Int], [Int]), v) -> v)
-> (([Int], [Int], [Int], [Int], [Int], [Int]), v)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (([Int], [Int], [Int], [Int], [Int], [Int]), v) -> v
forall a b. (a, b) -> b
snd) ([(([Int], [Int], [Int], [Int], [Int], [Int]), v)]
 -> [(([Int], [Int], [Int], [Int], [Int], [Int]), v)])
-> [(([Int], [Int], [Int], [Int], [Int], [Int]), v)]
-> [(([Int], [Int], [Int], [Int], [Int], [Int]), v)]
forall a b. (a -> b) -> a -> b
$ (((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3),
  v)
 -> (([Int], [Int], [Int], [Int], [Int], [Int]), v))
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3),
     v)]
-> [(([Int], [Int], [Int], [Int], [Int], [Int]), v)]
forall a b. (a -> b) -> [a] -> [b]
map (\((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3)
x,v
y) -> ((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3)
-> ([Int], [Int], [Int], [Int], [Int], [Int])
forall a a a a a a (t :: * -> *) (t :: * -> *) (t :: * -> *)
       (t :: * -> *) (t :: * -> *) (t :: * -> *).
(Enum a, Enum a, Enum a, Enum a, Enum a, Enum a, Foldable t,
 Foldable t, Foldable t, Foldable t, Foldable t, Foldable t) =>
(t a, t a, t a, t a, t a, t a)
-> ([Int], [Int], [Int], [Int], [Int], [Int])
showInd (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3)
x, v
y)) [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3),
  v)]
l
        where
            l :: [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3),
  v)]
l = AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3),
     v)]
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) k1 k2 k3 v.
AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)]
toListT6 AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
t
            showInd :: (t a, t a, t a, t a, t a, t a)
-> ([Int], [Int], [Int], [Int], [Int], [Int])
showInd (t a
i1,t a
i2,t a
i3,t a
i4,t a
i5,t a
i6) = ((a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i1), (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i2),
                                        (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i3), (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i4),
                                        (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i5), (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i6))

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)]
toListT7' :: AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
-> [(([Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)]
toListT7' AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
t = ((([Int], [Int], [Int], [Int], [Int], [Int], [Int]), v) -> Bool)
-> [(([Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)]
-> [(([Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> ((([Int], [Int], [Int], [Int], [Int], [Int], [Int]), v) -> Bool)
-> (([Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v -> Bool
forall a. TAdd a => a -> Bool
scaleZero (v -> Bool)
-> ((([Int], [Int], [Int], [Int], [Int], [Int], [Int]), v) -> v)
-> (([Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (([Int], [Int], [Int], [Int], [Int], [Int], [Int]), v) -> v
forall a b. (a, b) -> b
snd) ([(([Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)]
 -> [(([Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)])
-> [(([Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)]
-> [(([Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)]
forall a b. (a -> b) -> a -> b
$ (((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3, IndList n7 k4),
  v)
 -> (([Int], [Int], [Int], [Int], [Int], [Int], [Int]), v))
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3, IndList n7 k4),
     v)]
-> [(([Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)]
forall a b. (a -> b) -> [a] -> [b]
map (\((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3, IndList n7 k4)
x,v
y) -> ((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3, IndList n7 k4)
-> ([Int], [Int], [Int], [Int], [Int], [Int], [Int])
forall a a a a a a a (t :: * -> *) (t :: * -> *) (t :: * -> *)
       (t :: * -> *) (t :: * -> *) (t :: * -> *) (t :: * -> *).
(Enum a, Enum a, Enum a, Enum a, Enum a, Enum a, Enum a,
 Foldable t, Foldable t, Foldable t, Foldable t, Foldable t,
 Foldable t, Foldable t) =>
(t a, t a, t a, t a, t a, t a, t a)
-> ([Int], [Int], [Int], [Int], [Int], [Int], [Int])
showInd (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3, IndList n7 k4)
x, v
y)) [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3, IndList n7 k4),
  v)]
l
        where
            l :: [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3, IndList n7 k4),
  v)]
l = AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3, IndList n7 k4),
     v)]
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4 v.
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)]
toListT7 AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
t
            showInd :: (t a, t a, t a, t a, t a, t a, t a)
-> ([Int], [Int], [Int], [Int], [Int], [Int], [Int])
showInd (t a
i1,t a
i2,t a
i3,t a
i4,t a
i5,t a
i6,t a
i7) = ((a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i1), (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i2),
                                        (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i3), (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i4),
                                        (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i5), (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i6),
                                        (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i7))

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)]
toListT8' :: AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
-> [(([Int], [Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)]
toListT8' AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
t = ((([Int], [Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)
 -> Bool)
-> [(([Int], [Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)]
-> [(([Int], [Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> ((([Int], [Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)
    -> Bool)
-> (([Int], [Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v -> Bool
forall a. TAdd a => a -> Bool
scaleZero (v -> Bool)
-> ((([Int], [Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)
    -> v)
-> (([Int], [Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (([Int], [Int], [Int], [Int], [Int], [Int], [Int], [Int]), v) -> v
forall a b. (a, b) -> b
snd) ([(([Int], [Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)]
 -> [(([Int], [Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)])
-> [(([Int], [Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)]
-> [(([Int], [Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)]
forall a b. (a -> b) -> a -> b
$ (((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3, IndList n7 k4, IndList n8 k4),
  v)
 -> (([Int], [Int], [Int], [Int], [Int], [Int], [Int], [Int]), v))
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3, IndList n7 k4, IndList n8 k4),
     v)]
-> [(([Int], [Int], [Int], [Int], [Int], [Int], [Int], [Int]), v)]
forall a b. (a -> b) -> [a] -> [b]
map (\((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3, IndList n7 k4, IndList n8 k4)
x,v
y) -> ((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3, IndList n7 k4, IndList n8 k4)
-> ([Int], [Int], [Int], [Int], [Int], [Int], [Int], [Int])
forall a a a a a a a a (t :: * -> *) (t :: * -> *) (t :: * -> *)
       (t :: * -> *) (t :: * -> *) (t :: * -> *) (t :: * -> *)
       (t :: * -> *).
(Enum a, Enum a, Enum a, Enum a, Enum a, Enum a, Enum a, Enum a,
 Foldable t, Foldable t, Foldable t, Foldable t, Foldable t,
 Foldable t, Foldable t, Foldable t) =>
(t a, t a, t a, t a, t a, t a, t a, t a)
-> ([Int], [Int], [Int], [Int], [Int], [Int], [Int], [Int])
showInd (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3, IndList n7 k4, IndList n8 k4)
x, v
y)) [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3, IndList n7 k4, IndList n8 k4),
  v)]
l
        where
            l :: [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3, IndList n7 k4, IndList n8 k4),
  v)]
l = AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3, IndList n7 k4, IndList n8 k4),
     v)]
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) (n8 :: Nat) k1 k2 k3 k4 v.
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)]
toListT8 AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
t
            showInd :: (t a, t a, t a, t a, t a, t a, t a, t a)
-> ([Int], [Int], [Int], [Int], [Int], [Int], [Int], [Int])
showInd (t a
i1,t a
i2,t a
i3,t a
i4,t a
i5,t a
i6,t a
i7,t a
i8) = ((a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i1), (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i2),
                                        (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i3), (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i4),
                                        (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i5), (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i6),
                                        (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i7), (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i8))


--convert to non type safe assocs list, all indices regardless of their type are collected in the [Int] list

toListShow1 :: (TIndex k1, TAdd v) => AbsTensor1 n1 k1 v -> [([Int],v)]
toListShow1 :: AbsTensor1 n1 k1 v -> [([Int], v)]
toListShow1 = AbsTensor1 n1 k1 v -> [([Int], v)]
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> [([Int], v)]
toListT'

toListShow2 :: (TIndex k1, TAdd v) => AbsTensor2 n1 n2 k1 v -> [([Int],v)]
toListShow2 :: AbsTensor2 n1 n2 k1 v -> [([Int], v)]
toListShow2 AbsTensor2 n1 n2 k1 v
t = (([Int], v) -> Bool) -> [([Int], v)] -> [([Int], v)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (([Int], v) -> Bool) -> ([Int], v) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v -> Bool
forall a. TAdd a => a -> Bool
scaleZero (v -> Bool) -> (([Int], v) -> v) -> ([Int], v) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], v) -> v
forall a b. (a, b) -> b
snd) ([([Int], v)] -> [([Int], v)]) -> [([Int], v)] -> [([Int], v)]
forall a b. (a -> b) -> a -> b
$ (((IndList n1 k1, IndList n2 k1), v) -> ([Int], v))
-> [((IndList n1 k1, IndList n2 k1), v)] -> [([Int], v)]
forall a b. (a -> b) -> [a] -> [b]
map (\((IndList n1 k1, IndList n2 k1)
x,v
y) -> ((IndList n1 k1, IndList n2 k1) -> [Int]
forall a a (t :: * -> *) (t :: * -> *).
(Enum a, Enum a, Foldable t, Foldable t) =>
(t a, t a) -> [Int]
showInd (IndList n1 k1, IndList n2 k1)
x, v
y)) [((IndList n1 k1, IndList n2 k1), v)]
l
        where
            l :: [((IndList n1 k1, IndList n2 k1), v)]
l = AbsTensor2 n1 n2 k1 v -> [((IndList n1 k1, IndList n2 k1), v)]
forall (n1 :: Nat) (n2 :: Nat) k1 v.
AbsTensor2 n1 n2 k1 v -> [(IndTuple2 n1 n2 k1, v)]
toListT2 AbsTensor2 n1 n2 k1 v
t
            showInd :: (t a, t a) -> [Int]
showInd (t a
i1,t a
i2) = (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i1) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++ (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i2)

toListShow3 :: (TIndex k1, TIndex k2, TAdd v) => AbsTensor3 n1 n2 n3 k1 k2 v -> [([Int],v)]
toListShow3 :: AbsTensor3 n1 n2 n3 k1 k2 v -> [([Int], v)]
toListShow3 AbsTensor3 n1 n2 n3 k1 k2 v
t = (([Int], v) -> Bool) -> [([Int], v)] -> [([Int], v)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (([Int], v) -> Bool) -> ([Int], v) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v -> Bool
forall a. TAdd a => a -> Bool
scaleZero (v -> Bool) -> (([Int], v) -> v) -> ([Int], v) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], v) -> v
forall a b. (a, b) -> b
snd) ([([Int], v)] -> [([Int], v)]) -> [([Int], v)] -> [([Int], v)]
forall a b. (a -> b) -> a -> b
$ (((IndList n1 k1, IndList n2 k1, IndList n3 k2), v) -> ([Int], v))
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2), v)]
-> [([Int], v)]
forall a b. (a -> b) -> [a] -> [b]
map (\((IndList n1 k1, IndList n2 k1, IndList n3 k2)
x,v
y) -> ((IndList n1 k1, IndList n2 k1, IndList n3 k2) -> [Int]
forall a a a (t :: * -> *) (t :: * -> *) (t :: * -> *).
(Enum a, Enum a, Enum a, Foldable t, Foldable t, Foldable t) =>
(t a, t a, t a) -> [Int]
showInd (IndList n1 k1, IndList n2 k1, IndList n3 k2)
x, v
y)) [((IndList n1 k1, IndList n2 k1, IndList n3 k2), v)]
l
        where
            l :: [((IndList n1 k1, IndList n2 k1, IndList n3 k2), v)]
l = AbsTensor3 n1 n2 n3 k1 k2 v
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2), v)]
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2 v.
AbsTensor3 n1 n2 n3 k1 k2 v -> [(IndTuple3 n1 n2 n3 k1 k2, v)]
toListT3 AbsTensor3 n1 n2 n3 k1 k2 v
t
            showInd :: (t a, t a, t a) -> [Int]
showInd (t a
i1,t a
i2,t a
i3) = (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i1) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++ (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i2) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++
                                 (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i3)

toListShow4 :: (TIndex k1, TIndex k2, TAdd v) => AbsTensor4 n1 n2 n3 n4 k1 k2 v -> [([Int],v)]
toListShow4 :: AbsTensor4 n1 n2 n3 n4 k1 k2 v -> [([Int], v)]
toListShow4 AbsTensor4 n1 n2 n3 n4 k1 k2 v
t = (([Int], v) -> Bool) -> [([Int], v)] -> [([Int], v)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (([Int], v) -> Bool) -> ([Int], v) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v -> Bool
forall a. TAdd a => a -> Bool
scaleZero (v -> Bool) -> (([Int], v) -> v) -> ([Int], v) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], v) -> v
forall a b. (a, b) -> b
snd) ([([Int], v)] -> [([Int], v)]) -> [([Int], v)] -> [([Int], v)]
forall a b. (a -> b) -> a -> b
$ (((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2), v)
 -> ([Int], v))
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     v)]
-> [([Int], v)]
forall a b. (a -> b) -> [a] -> [b]
map (\((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2)
x,v
y) -> ((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2)
-> [Int]
forall a a a a (t :: * -> *) (t :: * -> *) (t :: * -> *)
       (t :: * -> *).
(Enum a, Enum a, Enum a, Enum a, Foldable t, Foldable t,
 Foldable t, Foldable t) =>
(t a, t a, t a, t a) -> [Int]
showInd (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2)
x, v
y)) [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2), v)]
l
        where
            l :: [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2), v)]
l = AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2),
     v)]
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2 v.
AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> [(IndTuple4 n1 n2 n3 n4 k1 k2, v)]
toListT4 AbsTensor4 n1 n2 n3 n4 k1 k2 v
t
            showInd :: (t a, t a, t a, t a) -> [Int]
showInd (t a
i1,t a
i2,t a
i3,t a
i4) = (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i1) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++ (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i2) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++
                                    (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i3) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++ (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i4)

toListShow5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> [([Int],v)]
toListShow5 :: AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> [([Int], v)]
toListShow5 AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
t = (([Int], v) -> Bool) -> [([Int], v)] -> [([Int], v)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (([Int], v) -> Bool) -> ([Int], v) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v -> Bool
forall a. TAdd a => a -> Bool
scaleZero (v -> Bool) -> (([Int], v) -> v) -> ([Int], v) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], v) -> v
forall a b. (a, b) -> b
snd) ([([Int], v)] -> [([Int], v)]) -> [([Int], v)] -> [([Int], v)]
forall a b. (a -> b) -> a -> b
$ (((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3),
  v)
 -> ([Int], v))
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     v)]
-> [([Int], v)]
forall a b. (a -> b) -> [a] -> [b]
map (\((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3)
x,v
y) -> ((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3)
-> [Int]
forall a a a a a (t :: * -> *) (t :: * -> *) (t :: * -> *)
       (t :: * -> *) (t :: * -> *).
(Enum a, Enum a, Enum a, Enum a, Enum a, Foldable t, Foldable t,
 Foldable t, Foldable t, Foldable t) =>
(t a, t a, t a, t a, t a) -> [Int]
showInd (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3)
x, v
y)) [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3),
  v)]
l
        where
            l :: [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3),
  v)]
l = AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3),
     v)]
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       k1 k2 k3 v.
AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> [(IndTuple5 n1 n2 n3 n4 n5 k1 k2 k3, v)]
toListT5 AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
t
            showInd :: (t a, t a, t a, t a, t a) -> [Int]
showInd (t a
i1,t a
i2,t a
i3,t a
i4,t a
i5) = (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i1) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++ (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i2) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++
                                    (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i3) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++ (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i4) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++
                                    (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i5)

toListShow6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd v) => AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> [([Int],v)]
toListShow6 :: AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> [([Int], v)]
toListShow6 AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
t = (([Int], v) -> Bool) -> [([Int], v)] -> [([Int], v)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (([Int], v) -> Bool) -> ([Int], v) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v -> Bool
forall a. TAdd a => a -> Bool
scaleZero (v -> Bool) -> (([Int], v) -> v) -> ([Int], v) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], v) -> v
forall a b. (a, b) -> b
snd) ([([Int], v)] -> [([Int], v)]) -> [([Int], v)] -> [([Int], v)]
forall a b. (a -> b) -> a -> b
$ (((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3),
  v)
 -> ([Int], v))
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3),
     v)]
-> [([Int], v)]
forall a b. (a -> b) -> [a] -> [b]
map (\((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3)
x,v
y) -> ((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3)
-> [Int]
forall a a a a a a (t :: * -> *) (t :: * -> *) (t :: * -> *)
       (t :: * -> *) (t :: * -> *) (t :: * -> *).
(Enum a, Enum a, Enum a, Enum a, Enum a, Enum a, Foldable t,
 Foldable t, Foldable t, Foldable t, Foldable t, Foldable t) =>
(t a, t a, t a, t a, t a, t a) -> [Int]
showInd (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3)
x, v
y)) [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3),
  v)]
l
        where
            l :: [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3),
  v)]
l = AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3),
     v)]
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) k1 k2 k3 v.
AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> [(IndTuple6 n1 n2 n3 n4 n5 n6 k1 k2 k3, v)]
toListT6 AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
t
            showInd :: (t a, t a, t a, t a, t a, t a) -> [Int]
showInd (t a
i1,t a
i2,t a
i3,t a
i4,t a
i5,t a
i6) = (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i1) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++ (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i2) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++
                                        (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i3) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++ (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i4) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++
                                        (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i5) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++ (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i6)

toListShow7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) => AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> [([Int],v)]
toListShow7 :: AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> [([Int], v)]
toListShow7 AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
t = (([Int], v) -> Bool) -> [([Int], v)] -> [([Int], v)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (([Int], v) -> Bool) -> ([Int], v) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v -> Bool
forall a. TAdd a => a -> Bool
scaleZero (v -> Bool) -> (([Int], v) -> v) -> ([Int], v) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], v) -> v
forall a b. (a, b) -> b
snd) ([([Int], v)] -> [([Int], v)]) -> [([Int], v)] -> [([Int], v)]
forall a b. (a -> b) -> a -> b
$ (((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3, IndList n7 k4),
  v)
 -> ([Int], v))
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3, IndList n7 k4),
     v)]
-> [([Int], v)]
forall a b. (a -> b) -> [a] -> [b]
map (\((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3, IndList n7 k4)
x,v
y) -> ((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3, IndList n7 k4)
-> [Int]
forall a a a a a a a (t :: * -> *) (t :: * -> *) (t :: * -> *)
       (t :: * -> *) (t :: * -> *) (t :: * -> *) (t :: * -> *).
(Enum a, Enum a, Enum a, Enum a, Enum a, Enum a, Enum a,
 Foldable t, Foldable t, Foldable t, Foldable t, Foldable t,
 Foldable t, Foldable t) =>
(t a, t a, t a, t a, t a, t a, t a) -> [Int]
showInd (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3, IndList n7 k4)
x, v
y)) [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3, IndList n7 k4),
  v)]
l
        where
            l :: [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3, IndList n7 k4),
  v)]
l = AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3, IndList n7 k4),
     v)]
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4 v.
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)]
toListT7 AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
t
            showInd :: (t a, t a, t a, t a, t a, t a, t a) -> [Int]
showInd (t a
i1,t a
i2,t a
i3,t a
i4,t a
i5,t a
i6,t a
i7) = (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i1) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++ (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i2) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++
                                        (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i3) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++ (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i4) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++
                                        (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i5) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++ (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i6) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++
                                        (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i7)

toListShow8 :: (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],v)]
toListShow8 :: AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> [([Int], v)]
toListShow8 AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
t = (([Int], v) -> Bool) -> [([Int], v)] -> [([Int], v)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (([Int], v) -> Bool) -> ([Int], v) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v -> Bool
forall a. TAdd a => a -> Bool
scaleZero (v -> Bool) -> (([Int], v) -> v) -> ([Int], v) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], v) -> v
forall a b. (a, b) -> b
snd) ([([Int], v)] -> [([Int], v)]) -> [([Int], v)] -> [([Int], v)]
forall a b. (a -> b) -> a -> b
$ (((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3, IndList n7 k4, IndList n8 k4),
  v)
 -> ([Int], v))
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3, IndList n7 k4, IndList n8 k4),
     v)]
-> [([Int], v)]
forall a b. (a -> b) -> [a] -> [b]
map (\((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3, IndList n7 k4, IndList n8 k4)
x,v
y) -> ((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3, IndList n7 k4, IndList n8 k4)
-> [Int]
forall a a a a a a a a (t :: * -> *) (t :: * -> *) (t :: * -> *)
       (t :: * -> *) (t :: * -> *) (t :: * -> *) (t :: * -> *)
       (t :: * -> *).
(Enum a, Enum a, Enum a, Enum a, Enum a, Enum a, Enum a, Enum a,
 Foldable t, Foldable t, Foldable t, Foldable t, Foldable t,
 Foldable t, Foldable t, Foldable t) =>
(t a, t a, t a, t a, t a, t a, t a, t a) -> [Int]
showInd (IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
 IndList n5 k3, IndList n6 k3, IndList n7 k4, IndList n8 k4)
x, v
y)) [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3, IndList n7 k4, IndList n8 k4),
  v)]
l
        where
            l :: [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
   IndList n5 k3, IndList n6 k3, IndList n7 k4, IndList n8 k4),
  v)]
l = AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
-> [((IndList n1 k1, IndList n2 k1, IndList n3 k2, IndList n4 k2,
      IndList n5 k3, IndList n6 k3, IndList n7 k4, IndList n8 k4),
     v)]
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) (n8 :: Nat) k1 k2 k3 k4 v.
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)]
toListT8 AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
t
            showInd :: (t a, t a, t a, t a, t a, t a, t a, t a) -> [Int]
showInd (t a
i1,t a
i2,t a
i3,t a
i4,t a
i5,t a
i6,t a
i7,t a
i8) = (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i1) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++ (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i2) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++
                                        (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i3) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++ (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i4) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++
                                        (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i5) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++ (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i6) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++
                                        (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i7) [Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++ (a -> Int) -> [a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map a -> Int
forall a. Enum a => a -> Int
fromEnum (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
i8)


--flatten tensor with ansVar values to assocs list

toListShowVar1 :: (TIndex k1, TAdd a) => AbsTensor1 n1 k1 (AnsVar a) -> [([Int], [(Int, a)])]
toListShowVar1 :: AbsTensor1 n1 k1 (AnsVar a) -> [([Int], [(Int, a)])]
toListShowVar1 AbsTensor1 n1 k1 (AnsVar a)
t = (([Int], [(Int, a)]) -> Bool)
-> [([Int], [(Int, a)])] -> [([Int], [(Int, a)])]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (([Int], [(Int, a)]) -> Bool) -> ([Int], [(Int, a)]) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Int, a)] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([(Int, a)] -> Bool)
-> (([Int], [(Int, a)]) -> [(Int, a)])
-> ([Int], [(Int, a)])
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [(Int, a)]) -> [(Int, a)]
forall a b. (a, b) -> b
snd) ([([Int], [(Int, a)])] -> [([Int], [(Int, a)])])
-> [([Int], [(Int, a)])] -> [([Int], [(Int, a)])]
forall a b. (a -> b) -> a -> b
$ (([Int], AnsVar a) -> ([Int], [(Int, a)]))
-> [([Int], AnsVar a)] -> [([Int], [(Int, a)])]
forall a b. (a -> b) -> [a] -> [b]
map (\([Int]
a,AnsVar IntMap a
b) -> ([Int]
a, ((Int, a) -> Bool) -> [(Int, a)] -> [(Int, a)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> ((Int, a) -> Bool) -> (Int, a) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Bool
forall a. TAdd a => a -> Bool
scaleZero (a -> Bool) -> ((Int, a) -> a) -> (Int, a) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, a) -> a
forall a b. (a, b) -> b
snd) ([(Int, a)] -> [(Int, a)]) -> [(Int, a)] -> [(Int, a)]
forall a b. (a -> b) -> a -> b
$ IntMap a -> [(Int, a)]
forall a. IntMap a -> [(Int, a)]
I.assocs IntMap a
b)) [([Int], AnsVar a)]
l
        where
            l :: [([Int], AnsVar a)]
l = AbsTensor1 n1 k1 (AnsVar a) -> [([Int], AnsVar a)]
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> [([Int], v)]
toListShow1 AbsTensor1 n1 k1 (AnsVar a)
t

toListShowVar2 :: (TIndex k1, TAdd a) => AbsTensor2 n1 n2 k1 (AnsVar a) -> [([Int], [(Int, a)])]
toListShowVar2 :: AbsTensor2 n1 n2 k1 (AnsVar a) -> [([Int], [(Int, a)])]
toListShowVar2 AbsTensor2 n1 n2 k1 (AnsVar a)
t = (([Int], [(Int, a)]) -> Bool)
-> [([Int], [(Int, a)])] -> [([Int], [(Int, a)])]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (([Int], [(Int, a)]) -> Bool) -> ([Int], [(Int, a)]) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Int, a)] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([(Int, a)] -> Bool)
-> (([Int], [(Int, a)]) -> [(Int, a)])
-> ([Int], [(Int, a)])
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [(Int, a)]) -> [(Int, a)]
forall a b. (a, b) -> b
snd) ([([Int], [(Int, a)])] -> [([Int], [(Int, a)])])
-> [([Int], [(Int, a)])] -> [([Int], [(Int, a)])]
forall a b. (a -> b) -> a -> b
$ (([Int], AnsVar a) -> ([Int], [(Int, a)]))
-> [([Int], AnsVar a)] -> [([Int], [(Int, a)])]
forall a b. (a -> b) -> [a] -> [b]
map (\([Int]
a,AnsVar IntMap a
b) -> ([Int]
a, ((Int, a) -> Bool) -> [(Int, a)] -> [(Int, a)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> ((Int, a) -> Bool) -> (Int, a) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Bool
forall a. TAdd a => a -> Bool
scaleZero (a -> Bool) -> ((Int, a) -> a) -> (Int, a) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, a) -> a
forall a b. (a, b) -> b
snd) ([(Int, a)] -> [(Int, a)]) -> [(Int, a)] -> [(Int, a)]
forall a b. (a -> b) -> a -> b
$ IntMap a -> [(Int, a)]
forall a. IntMap a -> [(Int, a)]
I.assocs IntMap a
b)) [([Int], AnsVar a)]
l
        where
            l :: [([Int], AnsVar a)]
l = AbsTensor2 n1 n2 k1 (AnsVar a) -> [([Int], AnsVar a)]
forall k1 v (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd v) =>
AbsTensor2 n1 n2 k1 v -> [([Int], v)]
toListShow2 AbsTensor2 n1 n2 k1 (AnsVar a)
t

toListShowVar3 :: (TIndex k1, TIndex k2, TAdd a) => AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a) -> [([Int], [(Int, a)])]
toListShowVar3 :: AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a) -> [([Int], [(Int, a)])]
toListShowVar3 AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a)
t = (([Int], [(Int, a)]) -> Bool)
-> [([Int], [(Int, a)])] -> [([Int], [(Int, a)])]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (([Int], [(Int, a)]) -> Bool) -> ([Int], [(Int, a)]) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Int, a)] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([(Int, a)] -> Bool)
-> (([Int], [(Int, a)]) -> [(Int, a)])
-> ([Int], [(Int, a)])
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [(Int, a)]) -> [(Int, a)]
forall a b. (a, b) -> b
snd) ([([Int], [(Int, a)])] -> [([Int], [(Int, a)])])
-> [([Int], [(Int, a)])] -> [([Int], [(Int, a)])]
forall a b. (a -> b) -> a -> b
$ (([Int], AnsVar a) -> ([Int], [(Int, a)]))
-> [([Int], AnsVar a)] -> [([Int], [(Int, a)])]
forall a b. (a -> b) -> [a] -> [b]
map (\([Int]
a,AnsVar IntMap a
b) -> ([Int]
a, ((Int, a) -> Bool) -> [(Int, a)] -> [(Int, a)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> ((Int, a) -> Bool) -> (Int, a) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Bool
forall a. TAdd a => a -> Bool
scaleZero (a -> Bool) -> ((Int, a) -> a) -> (Int, a) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, a) -> a
forall a b. (a, b) -> b
snd) ([(Int, a)] -> [(Int, a)]) -> [(Int, a)] -> [(Int, a)]
forall a b. (a -> b) -> a -> b
$ IntMap a -> [(Int, a)]
forall a. IntMap a -> [(Int, a)]
I.assocs IntMap a
b)) [([Int], AnsVar a)]
l
        where
            l :: [([Int], AnsVar a)]
l = AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a) -> [([Int], AnsVar a)]
forall k1 k2 v (n1 :: Nat) (n2 :: Nat) (n3 :: Nat).
(TIndex k1, TIndex k2, TAdd v) =>
AbsTensor3 n1 n2 n3 k1 k2 v -> [([Int], v)]
toListShow3 AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a)
t

toListShowVar4 :: (TIndex k1, TIndex k2, TAdd a) => AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a) -> [([Int], [(Int, a)])]
toListShowVar4 :: AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a) -> [([Int], [(Int, a)])]
toListShowVar4 AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a)
t = (([Int], [(Int, a)]) -> Bool)
-> [([Int], [(Int, a)])] -> [([Int], [(Int, a)])]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (([Int], [(Int, a)]) -> Bool) -> ([Int], [(Int, a)]) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Int, a)] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([(Int, a)] -> Bool)
-> (([Int], [(Int, a)]) -> [(Int, a)])
-> ([Int], [(Int, a)])
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [(Int, a)]) -> [(Int, a)]
forall a b. (a, b) -> b
snd) ([([Int], [(Int, a)])] -> [([Int], [(Int, a)])])
-> [([Int], [(Int, a)])] -> [([Int], [(Int, a)])]
forall a b. (a -> b) -> a -> b
$ (([Int], AnsVar a) -> ([Int], [(Int, a)]))
-> [([Int], AnsVar a)] -> [([Int], [(Int, a)])]
forall a b. (a -> b) -> [a] -> [b]
map (\([Int]
a,AnsVar IntMap a
b) -> ([Int]
a, ((Int, a) -> Bool) -> [(Int, a)] -> [(Int, a)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> ((Int, a) -> Bool) -> (Int, a) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Bool
forall a. TAdd a => a -> Bool
scaleZero (a -> Bool) -> ((Int, a) -> a) -> (Int, a) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, a) -> a
forall a b. (a, b) -> b
snd) ([(Int, a)] -> [(Int, a)]) -> [(Int, a)] -> [(Int, a)]
forall a b. (a -> b) -> a -> b
$ IntMap a -> [(Int, a)]
forall a. IntMap a -> [(Int, a)]
I.assocs IntMap a
b)) [([Int], AnsVar a)]
l
        where
            l :: [([Int], AnsVar a)]
l = AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a) -> [([Int], AnsVar a)]
forall k1 k2 v (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat).
(TIndex k1, TIndex k2, TAdd v) =>
AbsTensor4 n1 n2 n3 n4 k1 k2 v -> [([Int], v)]
toListShow4 AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a)
t

toListShowVar5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd a) => AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a) -> [([Int], [(Int, a)])]
toListShowVar5 :: AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a)
-> [([Int], [(Int, a)])]
toListShowVar5 AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a)
t = (([Int], [(Int, a)]) -> Bool)
-> [([Int], [(Int, a)])] -> [([Int], [(Int, a)])]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (([Int], [(Int, a)]) -> Bool) -> ([Int], [(Int, a)]) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Int, a)] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([(Int, a)] -> Bool)
-> (([Int], [(Int, a)]) -> [(Int, a)])
-> ([Int], [(Int, a)])
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [(Int, a)]) -> [(Int, a)]
forall a b. (a, b) -> b
snd) ([([Int], [(Int, a)])] -> [([Int], [(Int, a)])])
-> [([Int], [(Int, a)])] -> [([Int], [(Int, a)])]
forall a b. (a -> b) -> a -> b
$ (([Int], AnsVar a) -> ([Int], [(Int, a)]))
-> [([Int], AnsVar a)] -> [([Int], [(Int, a)])]
forall a b. (a -> b) -> [a] -> [b]
map (\([Int]
a,AnsVar IntMap a
b) -> ([Int]
a, ((Int, a) -> Bool) -> [(Int, a)] -> [(Int, a)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> ((Int, a) -> Bool) -> (Int, a) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Bool
forall a. TAdd a => a -> Bool
scaleZero (a -> Bool) -> ((Int, a) -> a) -> (Int, a) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, a) -> a
forall a b. (a, b) -> b
snd) ([(Int, a)] -> [(Int, a)]) -> [(Int, a)] -> [(Int, a)]
forall a b. (a -> b) -> a -> b
$ IntMap a -> [(Int, a)]
forall a. IntMap a -> [(Int, a)]
I.assocs IntMap a
b)) [([Int], AnsVar a)]
l
        where
            l :: [([Int], AnsVar a)]
l = AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a)
-> [([Int], AnsVar a)]
forall k1 k2 k3 v (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat).
(TIndex k1, TIndex k2, TIndex k3, TAdd v) =>
AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> [([Int], v)]
toListShow5 AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a)
t

toListShowVar6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd a) => AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a)  -> [([Int], [(Int, a)])]
toListShowVar6 :: AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a)
-> [([Int], [(Int, a)])]
toListShowVar6 AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a)
t = (([Int], [(Int, a)]) -> Bool)
-> [([Int], [(Int, a)])] -> [([Int], [(Int, a)])]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (([Int], [(Int, a)]) -> Bool) -> ([Int], [(Int, a)]) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Int, a)] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([(Int, a)] -> Bool)
-> (([Int], [(Int, a)]) -> [(Int, a)])
-> ([Int], [(Int, a)])
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [(Int, a)]) -> [(Int, a)]
forall a b. (a, b) -> b
snd) ([([Int], [(Int, a)])] -> [([Int], [(Int, a)])])
-> [([Int], [(Int, a)])] -> [([Int], [(Int, a)])]
forall a b. (a -> b) -> a -> b
$ (([Int], AnsVar a) -> ([Int], [(Int, a)]))
-> [([Int], AnsVar a)] -> [([Int], [(Int, a)])]
forall a b. (a -> b) -> [a] -> [b]
map (\([Int]
a,AnsVar IntMap a
b) -> ([Int]
a, ((Int, a) -> Bool) -> [(Int, a)] -> [(Int, a)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> ((Int, a) -> Bool) -> (Int, a) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Bool
forall a. TAdd a => a -> Bool
scaleZero (a -> Bool) -> ((Int, a) -> a) -> (Int, a) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, a) -> a
forall a b. (a, b) -> b
snd) ([(Int, a)] -> [(Int, a)]) -> [(Int, a)] -> [(Int, a)]
forall a b. (a -> b) -> a -> b
$ IntMap a -> [(Int, a)]
forall a. IntMap a -> [(Int, a)]
I.assocs IntMap a
b)) [([Int], AnsVar a)]
l
        where
            l :: [([Int], AnsVar a)]
l = AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a)
-> [([Int], AnsVar a)]
forall k1 k2 k3 v (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat).
(TIndex k1, TIndex k2, TIndex k3, TAdd v) =>
AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> [([Int], v)]
toListShow6 AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a)
t

toListShowVar7 :: (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)])]
toListShowVar7 :: AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar a)
-> [([Int], [(Int, a)])]
toListShowVar7 AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar a)
t = (([Int], [(Int, a)]) -> Bool)
-> [([Int], [(Int, a)])] -> [([Int], [(Int, a)])]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (([Int], [(Int, a)]) -> Bool) -> ([Int], [(Int, a)]) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Int, a)] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([(Int, a)] -> Bool)
-> (([Int], [(Int, a)]) -> [(Int, a)])
-> ([Int], [(Int, a)])
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [(Int, a)]) -> [(Int, a)]
forall a b. (a, b) -> b
snd) ([([Int], [(Int, a)])] -> [([Int], [(Int, a)])])
-> [([Int], [(Int, a)])] -> [([Int], [(Int, a)])]
forall a b. (a -> b) -> a -> b
$ (([Int], AnsVar a) -> ([Int], [(Int, a)]))
-> [([Int], AnsVar a)] -> [([Int], [(Int, a)])]
forall a b. (a -> b) -> [a] -> [b]
map (\([Int]
a,AnsVar IntMap a
b) -> ([Int]
a, ((Int, a) -> Bool) -> [(Int, a)] -> [(Int, a)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> ((Int, a) -> Bool) -> (Int, a) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Bool
forall a. TAdd a => a -> Bool
scaleZero (a -> Bool) -> ((Int, a) -> a) -> (Int, a) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, a) -> a
forall a b. (a, b) -> b
snd) ([(Int, a)] -> [(Int, a)]) -> [(Int, a)] -> [(Int, a)]
forall a b. (a -> b) -> a -> b
$ IntMap a -> [(Int, a)]
forall a. IntMap a -> [(Int, a)]
I.assocs IntMap a
b)) [([Int], AnsVar a)]
l
        where
            l :: [([Int], AnsVar a)]
l = AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar a)
-> [([Int], AnsVar a)]
forall k1 k2 k3 k4 v (n1 :: Nat) (n2 :: Nat) (n3 :: Nat)
       (n4 :: Nat) (n5 :: Nat) (n6 :: Nat) (n7 :: Nat).
(TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd v) =>
AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> [([Int], v)]
toListShow7 AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar a)
t

toListShowVar8 :: (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)])]
toListShowVar8 :: AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar a)
-> [([Int], [(Int, a)])]
toListShowVar8 AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar a)
t = (([Int], [(Int, a)]) -> Bool)
-> [([Int], [(Int, a)])] -> [([Int], [(Int, a)])]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (([Int], [(Int, a)]) -> Bool) -> ([Int], [(Int, a)]) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Int, a)] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([(Int, a)] -> Bool)
-> (([Int], [(Int, a)]) -> [(Int, a)])
-> ([Int], [(Int, a)])
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int], [(Int, a)]) -> [(Int, a)]
forall a b. (a, b) -> b
snd) ([([Int], [(Int, a)])] -> [([Int], [(Int, a)])])
-> [([Int], [(Int, a)])] -> [([Int], [(Int, a)])]
forall a b. (a -> b) -> a -> b
$ (([Int], AnsVar a) -> ([Int], [(Int, a)]))
-> [([Int], AnsVar a)] -> [([Int], [(Int, a)])]
forall a b. (a -> b) -> [a] -> [b]
map (\([Int]
a,AnsVar IntMap a
b) -> ([Int]
a, ((Int, a) -> Bool) -> [(Int, a)] -> [(Int, a)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> ((Int, a) -> Bool) -> (Int, a) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Bool
forall a. TAdd a => a -> Bool
scaleZero (a -> Bool) -> ((Int, a) -> a) -> (Int, a) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, a) -> a
forall a b. (a, b) -> b
snd) ([(Int, a)] -> [(Int, a)]) -> [(Int, a)] -> [(Int, a)]
forall a b. (a -> b) -> a -> b
$ IntMap a -> [(Int, a)]
forall a. IntMap a -> [(Int, a)]
I.assocs IntMap a
b)) [([Int], AnsVar a)]
l
        where
            l :: [([Int], AnsVar a)]
l = AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar a)
-> [([Int], AnsVar a)]
forall k1 k2 k3 k4 v (n1 :: Nat) (n2 :: Nat) (n3 :: Nat)
       (n4 :: Nat) (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) (n8 :: Nat).
(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], v)]
toListShow8 AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar a)
t

--write the tensor data into a matrix: columns label the occurring AnsVars (note that this is possible as we restricted to the case where the vars only occur linearly)
--rows label the non zero entries in the tensor

toMatList1' :: (TIndex k1, TAdd a) => AbsTensor1 n1 k1 (AnsVar a) -> [[(Int, a)]]
toMatList1' :: AbsTensor1 n1 k1 (AnsVar a) -> [[(Int, a)]]
toMatList1' AbsTensor1 n1 k1 (AnsVar a)
t = (([Int], [(Int, a)]) -> [(Int, a)])
-> [([Int], [(Int, a)])] -> [[(Int, a)]]
forall a b. (a -> b) -> [a] -> [b]
map ([Int], [(Int, a)]) -> [(Int, a)]
forall a b. (a, b) -> b
snd ([([Int], [(Int, a)])] -> [[(Int, a)]])
-> [([Int], [(Int, a)])] -> [[(Int, a)]]
forall a b. (a -> b) -> a -> b
$ AbsTensor1 n1 k1 (AnsVar a) -> [([Int], [(Int, a)])]
forall k1 a (n1 :: Nat).
(TIndex k1, TAdd a) =>
AbsTensor1 n1 k1 (AnsVar a) -> [([Int], [(Int, a)])]
toListShowVar1 AbsTensor1 n1 k1 (AnsVar a)
t

toMatList2' :: (TIndex k1, TAdd a) => AbsTensor2 n1 n2 k1 (AnsVar a) -> [[(Int, a)]]
toMatList2' :: AbsTensor2 n1 n2 k1 (AnsVar a) -> [[(Int, a)]]
toMatList2' AbsTensor2 n1 n2 k1 (AnsVar a)
t = (([Int], [(Int, a)]) -> [(Int, a)])
-> [([Int], [(Int, a)])] -> [[(Int, a)]]
forall a b. (a -> b) -> [a] -> [b]
map ([Int], [(Int, a)]) -> [(Int, a)]
forall a b. (a, b) -> b
snd ([([Int], [(Int, a)])] -> [[(Int, a)]])
-> [([Int], [(Int, a)])] -> [[(Int, a)]]
forall a b. (a -> b) -> a -> b
$ AbsTensor2 n1 n2 k1 (AnsVar a) -> [([Int], [(Int, a)])]
forall k1 a (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd a) =>
AbsTensor2 n1 n2 k1 (AnsVar a) -> [([Int], [(Int, a)])]
toListShowVar2 AbsTensor2 n1 n2 k1 (AnsVar a)
t

toMatList3' :: (TIndex k1, TIndex k2, TAdd a) => AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a) -> [[(Int, a)]]
toMatList3' :: AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a) -> [[(Int, a)]]
toMatList3' AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a)
t = (([Int], [(Int, a)]) -> [(Int, a)])
-> [([Int], [(Int, a)])] -> [[(Int, a)]]
forall a b. (a -> b) -> [a] -> [b]
map ([Int], [(Int, a)]) -> [(Int, a)]
forall a b. (a, b) -> b
snd ([([Int], [(Int, a)])] -> [[(Int, a)]])
-> [([Int], [(Int, a)])] -> [[(Int, a)]]
forall a b. (a -> b) -> a -> b
$ AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a) -> [([Int], [(Int, a)])]
forall k1 k2 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat).
(TIndex k1, TIndex k2, TAdd a) =>
AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a) -> [([Int], [(Int, a)])]
toListShowVar3 AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a)
t

toMatList4' :: (TIndex k1, TIndex k2, TAdd a) => AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a) -> [[(Int, a)]]
toMatList4' :: AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a) -> [[(Int, a)]]
toMatList4' AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a)
t = (([Int], [(Int, a)]) -> [(Int, a)])
-> [([Int], [(Int, a)])] -> [[(Int, a)]]
forall a b. (a -> b) -> [a] -> [b]
map ([Int], [(Int, a)]) -> [(Int, a)]
forall a b. (a, b) -> b
snd ([([Int], [(Int, a)])] -> [[(Int, a)]])
-> [([Int], [(Int, a)])] -> [[(Int, a)]]
forall a b. (a -> b) -> a -> b
$ AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a) -> [([Int], [(Int, a)])]
forall k1 k2 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat).
(TIndex k1, TIndex k2, TAdd a) =>
AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a) -> [([Int], [(Int, a)])]
toListShowVar4 AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a)
t

toMatList5' :: (TIndex k1, TIndex k2, TIndex k3, TAdd a) => AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a) -> [[(Int, a)]]
toMatList5' :: AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a) -> [[(Int, a)]]
toMatList5' AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a)
t = (([Int], [(Int, a)]) -> [(Int, a)])
-> [([Int], [(Int, a)])] -> [[(Int, a)]]
forall a b. (a -> b) -> [a] -> [b]
map ([Int], [(Int, a)]) -> [(Int, a)]
forall a b. (a, b) -> b
snd ([([Int], [(Int, a)])] -> [[(Int, a)]])
-> [([Int], [(Int, a)])] -> [[(Int, a)]]
forall a b. (a -> b) -> a -> b
$ AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a)
-> [([Int], [(Int, a)])]
forall k1 k2 k3 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat).
(TIndex k1, TIndex k2, TIndex k3, TAdd a) =>
AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a)
-> [([Int], [(Int, a)])]
toListShowVar5 AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a)
t

toMatList6' :: (TIndex k1, TIndex k2, TIndex k3, TAdd a) => AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a) -> [[(Int, a)]]
toMatList6' :: AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a) -> [[(Int, a)]]
toMatList6' AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a)
t = (([Int], [(Int, a)]) -> [(Int, a)])
-> [([Int], [(Int, a)])] -> [[(Int, a)]]
forall a b. (a -> b) -> [a] -> [b]
map ([Int], [(Int, a)]) -> [(Int, a)]
forall a b. (a, b) -> b
snd ([([Int], [(Int, a)])] -> [[(Int, a)]])
-> [([Int], [(Int, a)])] -> [[(Int, a)]]
forall a b. (a -> b) -> a -> b
$ AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a)
-> [([Int], [(Int, a)])]
forall k1 k2 k3 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat).
(TIndex k1, TIndex k2, TIndex k3, TAdd a) =>
AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a)
-> [([Int], [(Int, a)])]
toListShowVar6 AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a)
t

toMatList7' :: (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, a)]]
toMatList7' :: AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar a)
-> [[(Int, a)]]
toMatList7' AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar a)
t = (([Int], [(Int, a)]) -> [(Int, a)])
-> [([Int], [(Int, a)])] -> [[(Int, a)]]
forall a b. (a -> b) -> [a] -> [b]
map ([Int], [(Int, a)]) -> [(Int, a)]
forall a b. (a, b) -> b
snd ([([Int], [(Int, a)])] -> [[(Int, a)]])
-> [([Int], [(Int, a)])] -> [[(Int, a)]]
forall a b. (a -> b) -> a -> b
$ AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar a)
-> [([Int], [(Int, a)])]
forall k1 k2 k3 k4 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat)
       (n4 :: Nat) (n5 :: Nat) (n6 :: Nat) (n7 :: Nat).
(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)])]
toListShowVar7 AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar a)
t

toMatList8' :: (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, a)]]
toMatList8' :: AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar a)
-> [[(Int, a)]]
toMatList8' AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar a)
t = (([Int], [(Int, a)]) -> [(Int, a)])
-> [([Int], [(Int, a)])] -> [[(Int, a)]]
forall a b. (a -> b) -> [a] -> [b]
map ([Int], [(Int, a)]) -> [(Int, a)]
forall a b. (a, b) -> b
snd ([([Int], [(Int, a)])] -> [[(Int, a)]])
-> [([Int], [(Int, a)])] -> [[(Int, a)]]
forall a b. (a -> b) -> a -> b
$ AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar a)
-> [([Int], [(Int, a)])]
forall k1 k2 k3 k4 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat)
       (n4 :: Nat) (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) (n8 :: Nat).
(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)])]
toListShowVar8 AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar a)
t

_normalize :: [(Int,Rational)] -> ([(Int,Rational)],Rational)
_normalize :: [(Int, Rational)] -> ([(Int, Rational)], Rational)
_normalize [] = ([],Rational
1)
_normalize ((Int
a,Rational
b) : [(Int, Rational)]
xs) = ((Int
a,Rational
1) (Int, Rational) -> [(Int, Rational)] -> [(Int, Rational)]
forall a. a -> [a] -> [a]
: ((Int, Rational) -> (Int, Rational))
-> [(Int, Rational)] -> [(Int, Rational)]
forall a b. (a -> b) -> [a] -> [b]
map (\(Int
x,Rational
y) -> (Int
x,Rational
y Rational -> Rational -> Rational
forall a. Fractional a => a -> a -> a
/ Rational
b)) [(Int, Rational)]
xs,Rational
b)

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

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

data TensList3 k1 k2 v where
    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
    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
    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
    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
    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
    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

-- | Usual map function for heterogeneous tensor lists.

mapTensList1 :: (forall n1. AbsTensor1 n1 k1 v -> b ) -> TensList1 k1 v -> [b]
mapTensList1 :: (forall (n1 :: Nat). AbsTensor1 n1 k1 v -> b)
-> TensList1 k1 v -> [b]
mapTensList1 forall (n1 :: Nat). AbsTensor1 n1 k1 v -> b
_ TensList1 k1 v
EmptyTList1 = []
mapTensList1 forall (n1 :: Nat). AbsTensor1 n1 k1 v -> b
f (AppendTList1 AbsTensor1 n1 k1 v
t TensList1 k1 v
l) = AbsTensor1 n1 k1 v -> b
forall (n1 :: Nat). AbsTensor1 n1 k1 v -> b
f AbsTensor1 n1 k1 v
t b -> [b] -> [b]
forall a. a -> [a] -> [a]
: (forall (n1 :: Nat). AbsTensor1 n1 k1 v -> b)
-> TensList1 k1 v -> [b]
forall k1 v b.
(forall (n1 :: Nat). AbsTensor1 n1 k1 v -> b)
-> TensList1 k1 v -> [b]
mapTensList1 forall (n1 :: Nat). AbsTensor1 n1 k1 v -> b
f TensList1 k1 v
l

mapTensList2 :: (forall n1 n2. AbsTensor2 n1 n2 k1 v -> b ) -> TensList2 k1 v -> [b]
mapTensList2 :: (forall (n1 :: Nat) (n2 :: Nat). AbsTensor2 n1 n2 k1 v -> b)
-> TensList2 k1 v -> [b]
mapTensList2 forall (n1 :: Nat) (n2 :: Nat). AbsTensor2 n1 n2 k1 v -> b
_ TensList2 k1 v
EmptyTList2 = []
mapTensList2 forall (n1 :: Nat) (n2 :: Nat). AbsTensor2 n1 n2 k1 v -> b
f (AppendTList2 AbsTensor2 n1 n2 k1 v
t TensList2 k1 v
l) = AbsTensor2 n1 n2 k1 v -> b
forall (n1 :: Nat) (n2 :: Nat). AbsTensor2 n1 n2 k1 v -> b
f AbsTensor2 n1 n2 k1 v
t b -> [b] -> [b]
forall a. a -> [a] -> [a]
: (forall (n1 :: Nat) (n2 :: Nat). AbsTensor2 n1 n2 k1 v -> b)
-> TensList2 k1 v -> [b]
forall k1 v b.
(forall (n1 :: Nat) (n2 :: Nat). AbsTensor2 n1 n2 k1 v -> b)
-> TensList2 k1 v -> [b]
mapTensList2 forall (n1 :: Nat) (n2 :: Nat). AbsTensor2 n1 n2 k1 v -> b
f TensList2 k1 v
l

mapTensList3 :: (forall n1 n2 n3. AbsTensor3 n1 n2 n3 k1 k2 v -> b ) -> TensList3 k1 k2 v -> [b]
mapTensList3 :: (forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat).
 AbsTensor3 n1 n2 n3 k1 k2 v -> b)
-> TensList3 k1 k2 v -> [b]
mapTensList3 forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat).
AbsTensor3 n1 n2 n3 k1 k2 v -> b
_ TensList3 k1 k2 v
EmptyTList3 = []
mapTensList3 forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat).
AbsTensor3 n1 n2 n3 k1 k2 v -> b
f (AppendTList3 AbsTensor3 n1 n2 n3 k1 k2 v
t TensList3 k1 k2 v
l) = AbsTensor3 n1 n2 n3 k1 k2 v -> b
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat).
AbsTensor3 n1 n2 n3 k1 k2 v -> b
f AbsTensor3 n1 n2 n3 k1 k2 v
t b -> [b] -> [b]
forall a. a -> [a] -> [a]
: (forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat).
 AbsTensor3 n1 n2 n3 k1 k2 v -> b)
-> TensList3 k1 k2 v -> [b]
forall k1 k2 v b.
(forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat).
 AbsTensor3 n1 n2 n3 k1 k2 v -> b)
-> TensList3 k1 k2 v -> [b]
mapTensList3 forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat).
AbsTensor3 n1 n2 n3 k1 k2 v -> b
f TensList3 k1 k2 v
l

mapTensList4 :: (forall n1 n2 n3 n4. AbsTensor4 n1 n2 n3 n4 k1 k2 v -> b ) -> TensList4 k1 k2 v -> [b]
mapTensList4 :: (forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat).
 AbsTensor4 n1 n2 n3 n4 k1 k2 v -> b)
-> TensList4 k1 k2 v -> [b]
mapTensList4 forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat).
AbsTensor4 n1 n2 n3 n4 k1 k2 v -> b
_ TensList4 k1 k2 v
EmptyTList4 = []
mapTensList4 forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat).
AbsTensor4 n1 n2 n3 n4 k1 k2 v -> b
f (AppendTList4 AbsTensor4 n1 n2 n3 n4 k1 k2 v
t TensList4 k1 k2 v
l) = AbsTensor4 n1 n2 n3 n4 k1 k2 v -> b
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat).
AbsTensor4 n1 n2 n3 n4 k1 k2 v -> b
f AbsTensor4 n1 n2 n3 n4 k1 k2 v
t b -> [b] -> [b]
forall a. a -> [a] -> [a]
: (forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat).
 AbsTensor4 n1 n2 n3 n4 k1 k2 v -> b)
-> TensList4 k1 k2 v -> [b]
forall k1 k2 v b.
(forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat).
 AbsTensor4 n1 n2 n3 n4 k1 k2 v -> b)
-> TensList4 k1 k2 v -> [b]
mapTensList4 forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat).
AbsTensor4 n1 n2 n3 n4 k1 k2 v -> b
f TensList4 k1 k2 v
l

mapTensList5 :: (forall n1 n2 n3 n4 n5. AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> b ) -> TensList5 k1 k2 k3 v -> [b]
mapTensList5 :: (forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
        (n5 :: Nat).
 AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> b)
-> TensList5 k1 k2 k3 v -> [b]
mapTensList5 forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat).
AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> b
_ TensList5 k1 k2 k3 v
EmptyTList5 = []
mapTensList5 forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat).
AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> b
f (AppendTList5 AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
t TensList5 k1 k2 k3 v
l) = AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> b
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat).
AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> b
f AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
t b -> [b] -> [b]
forall a. a -> [a] -> [a]
: (forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
        (n5 :: Nat).
 AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> b)
-> TensList5 k1 k2 k3 v -> [b]
forall k1 k2 k3 v b.
(forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
        (n5 :: Nat).
 AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> b)
-> TensList5 k1 k2 k3 v -> [b]
mapTensList5 forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat).
AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> b
f TensList5 k1 k2 k3 v
l

mapTensList6 :: (forall n1 n2 n3 n4 n5 n6. AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> b ) -> TensList6 k1 k2 k3 v -> [b]
mapTensList6 :: (forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
        (n6 :: Nat).
 AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> b)
-> TensList6 k1 k2 k3 v -> [b]
mapTensList6 forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat).
AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> b
_ TensList6 k1 k2 k3 v
EmptyTList6 = []
mapTensList6 forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat).
AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> b
f (AppendTList6 AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
t TensList6 k1 k2 k3 v
l) = AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> b
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat).
AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> b
f AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
t b -> [b] -> [b]
forall a. a -> [a] -> [a]
: (forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
        (n6 :: Nat).
 AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> b)
-> TensList6 k1 k2 k3 v -> [b]
forall k1 k2 k3 v b.
(forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
        (n6 :: Nat).
 AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> b)
-> TensList6 k1 k2 k3 v -> [b]
mapTensList6 forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat).
AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> b
f TensList6 k1 k2 k3 v
l

mapTensList7 :: (forall n1 n2 n3 n4 n5 n6 n7. AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> b ) -> TensList7 k1 k2 k3 k4 v -> [b]
mapTensList7 :: (forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
        (n6 :: Nat) (n7 :: Nat).
 AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> b)
-> TensList7 k1 k2 k3 k4 v -> [b]
mapTensList7 forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat).
AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> b
_ TensList7 k1 k2 k3 k4 v
EmptyTList7 = []
mapTensList7 forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat).
AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> b
f (AppendTList7 AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
t TensList7 k1 k2 k3 k4 v
l) = AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> b
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat).
AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> b
f AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
t b -> [b] -> [b]
forall a. a -> [a] -> [a]
: (forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
        (n6 :: Nat) (n7 :: Nat).
 AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> b)
-> TensList7 k1 k2 k3 k4 v -> [b]
forall k1 k2 k3 k4 v b.
(forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
        (n6 :: Nat) (n7 :: Nat).
 AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> b)
-> TensList7 k1 k2 k3 k4 v -> [b]
mapTensList7 forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat).
AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> b
f TensList7 k1 k2 k3 k4 v
l

mapTensList8 :: (forall n1 n2 n3 n4 n5 n6 n7 n8. AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> b ) -> TensList8 k1 k2 k3 k4 v -> [b]
mapTensList8 :: (forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
        (n6 :: Nat) (n7 :: Nat) (n8 :: Nat).
 AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> b)
-> TensList8 k1 k2 k3 k4 v -> [b]
mapTensList8 forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) (n8 :: Nat).
AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> b
_ TensList8 k1 k2 k3 k4 v
EmptyTList8 = []
mapTensList8 forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) (n8 :: Nat).
AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> b
f (AppendTList8 AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
t TensList8 k1 k2 k3 k4 v
l) = AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> b
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) (n8 :: Nat).
AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> b
f AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
t b -> [b] -> [b]
forall a. a -> [a] -> [a]
: (forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
        (n6 :: Nat) (n7 :: Nat) (n8 :: Nat).
 AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> b)
-> TensList8 k1 k2 k3 k4 v -> [b]
forall k1 k2 k3 k4 v b.
(forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
        (n6 :: Nat) (n7 :: Nat) (n8 :: Nat).
 AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> b)
-> TensList8 k1 k2 k3 k4 v -> [b]
mapTensList8 forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) (n8 :: Nat).
AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> b
f TensList8 k1 k2 k3 k4 v
l

infixr 5 ...>

(...>) :: AbsTensor1 n1 k1 v -> TensList1 k1 v -> TensList1 k1 v
...> :: AbsTensor1 n1 k1 v -> TensList1 k1 v -> TensList1 k1 v
(...>) = AbsTensor1 n1 k1 v -> TensList1 k1 v -> TensList1 k1 v
forall (n1 :: Nat) k1 v.
AbsTensor1 n1 k1 v -> TensList1 k1 v -> TensList1 k1 v
AppendTList1


singletonTList1 :: AbsTensor1 n1 k1 v -> TensList1 k1 v
singletonTList1 :: AbsTensor1 n1 k1 v -> TensList1 k1 v
singletonTList1 AbsTensor1 n1 k1 v
t = AbsTensor1 n1 k1 v
t AbsTensor1 n1 k1 v -> TensList1 k1 v -> TensList1 k1 v
forall (n1 :: Nat) k1 v.
AbsTensor1 n1 k1 v -> TensList1 k1 v -> TensList1 k1 v
...> TensList1 k1 v
forall k1 v. TensList1 k1 v
EmptyTList1

infixr 5  ...+

(...+) :: TensList1 k1 v -> TensList1 k1 v -> TensList1 k1 v
...+ :: TensList1 k1 v -> TensList1 k1 v -> TensList1 k1 v
(...+) TensList1 k1 v
EmptyTList1 TensList1 k1 v
t1 = TensList1 k1 v
t1
(...+) TensList1 k1 v
t1 TensList1 k1 v
EmptyTList1 = TensList1 k1 v
t1
(...+) (AppendTList1 AbsTensor1 n1 k1 v
t1 TensList1 k1 v
EmptyTList1) TensList1 k1 v
t2 = AbsTensor1 n1 k1 v -> TensList1 k1 v -> TensList1 k1 v
forall (n1 :: Nat) k1 v.
AbsTensor1 n1 k1 v -> TensList1 k1 v -> TensList1 k1 v
AppendTList1 AbsTensor1 n1 k1 v
t1 TensList1 k1 v
t2
(...+) (AppendTList1 AbsTensor1 n1 k1 v
t1 TensList1 k1 v
t1') TensList1 k1 v
t2 = AbsTensor1 n1 k1 v -> TensList1 k1 v -> TensList1 k1 v
forall (n1 :: Nat) k1 v.
AbsTensor1 n1 k1 v -> TensList1 k1 v -> TensList1 k1 v
AppendTList1 AbsTensor1 n1 k1 v
t1 (TensList1 k1 v
t1' TensList1 k1 v -> TensList1 k1 v -> TensList1 k1 v
forall k1 v. TensList1 k1 v -> TensList1 k1 v -> TensList1 k1 v
...+ TensList1 k1 v
t2)


infixr 5 ..&>

(..&>) :: AbsTensor2 n1 n2 k1 v -> TensList2 k1 v -> TensList2 k1 v
..&> :: AbsTensor2 n1 n2 k1 v -> TensList2 k1 v -> TensList2 k1 v
(..&>) = AbsTensor2 n1 n2 k1 v -> TensList2 k1 v -> TensList2 k1 v
forall (n1 :: Nat) (n2 :: Nat) k1 v.
AbsTensor2 n1 n2 k1 v -> TensList2 k1 v -> TensList2 k1 v
AppendTList2

singletonTList2 :: AbsTensor2 n1 n2 k1 v -> TensList2 k1 v
singletonTList2 :: AbsTensor2 n1 n2 k1 v -> TensList2 k1 v
singletonTList2 AbsTensor2 n1 n2 k1 v
t = AbsTensor2 n1 n2 k1 v
t AbsTensor2 n1 n2 k1 v -> TensList2 k1 v -> TensList2 k1 v
forall (n1 :: Nat) (n2 :: Nat) k1 v.
AbsTensor2 n1 n2 k1 v -> TensList2 k1 v -> TensList2 k1 v
..&> TensList2 k1 v
forall k1 v. TensList2 k1 v
EmptyTList2

infixr 5 ..&+

(..&+) :: TensList2 k1 v -> TensList2 k1 v -> TensList2 k1 v
..&+ :: TensList2 k1 v -> TensList2 k1 v -> TensList2 k1 v
(..&+) TensList2 k1 v
EmptyTList2 TensList2 k1 v
t1 = TensList2 k1 v
t1
(..&+) TensList2 k1 v
t1 TensList2 k1 v
EmptyTList2 = TensList2 k1 v
t1
(..&+) (AppendTList2 AbsTensor2 n1 n2 k1 v
t1 TensList2 k1 v
EmptyTList2) TensList2 k1 v
t2 = AbsTensor2 n1 n2 k1 v -> TensList2 k1 v -> TensList2 k1 v
forall (n1 :: Nat) (n2 :: Nat) k1 v.
AbsTensor2 n1 n2 k1 v -> TensList2 k1 v -> TensList2 k1 v
AppendTList2 AbsTensor2 n1 n2 k1 v
t1 TensList2 k1 v
t2
(..&+) (AppendTList2 AbsTensor2 n1 n2 k1 v
t1 TensList2 k1 v
t1') TensList2 k1 v
t2 = AbsTensor2 n1 n2 k1 v -> TensList2 k1 v -> TensList2 k1 v
forall (n1 :: Nat) (n2 :: Nat) k1 v.
AbsTensor2 n1 n2 k1 v -> TensList2 k1 v -> TensList2 k1 v
AppendTList2 AbsTensor2 n1 n2 k1 v
t1 (TensList2 k1 v
t1' TensList2 k1 v -> TensList2 k1 v -> TensList2 k1 v
forall k1 v. TensList2 k1 v -> TensList2 k1 v -> TensList2 k1 v
..&+ TensList2 k1 v
t2)


infixr 5 .&.>

(.&.>) :: AbsTensor3 n1 n2 n3 k1 k2 v -> TensList3 k1 k2 v -> TensList3 k1 k2 v
.&.> :: AbsTensor3 n1 n2 n3 k1 k2 v
-> TensList3 k1 k2 v -> TensList3 k1 k2 v
(.&.>) = AbsTensor3 n1 n2 n3 k1 k2 v
-> TensList3 k1 k2 v -> TensList3 k1 k2 v
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2 v.
AbsTensor3 n1 n2 n3 k1 k2 v
-> TensList3 k1 k2 v -> TensList3 k1 k2 v
AppendTList3

singletonTList3 :: AbsTensor3 n1 n2 n3 k1 k2 v -> TensList3 k1 k2 v
singletonTList3 :: AbsTensor3 n1 n2 n3 k1 k2 v -> TensList3 k1 k2 v
singletonTList3 AbsTensor3 n1 n2 n3 k1 k2 v
t = AbsTensor3 n1 n2 n3 k1 k2 v
t AbsTensor3 n1 n2 n3 k1 k2 v
-> TensList3 k1 k2 v -> TensList3 k1 k2 v
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2 v.
AbsTensor3 n1 n2 n3 k1 k2 v
-> TensList3 k1 k2 v -> TensList3 k1 k2 v
.&.> TensList3 k1 k2 v
forall k1 k2 v. TensList3 k1 k2 v
EmptyTList3

infixr 5 .&.+

(.&.+) :: TensList3 k1 k2 v -> TensList3 k1 k2 v -> TensList3 k1 k2 v
.&.+ :: TensList3 k1 k2 v -> TensList3 k1 k2 v -> TensList3 k1 k2 v
(.&.+) TensList3 k1 k2 v
EmptyTList3 TensList3 k1 k2 v
t1 = TensList3 k1 k2 v
t1
(.&.+) TensList3 k1 k2 v
t1 TensList3 k1 k2 v
EmptyTList3 = TensList3 k1 k2 v
t1
(.&.+) (AppendTList3 AbsTensor3 n1 n2 n3 k1 k2 v
t1 TensList3 k1 k2 v
EmptyTList3) TensList3 k1 k2 v
t2 = AbsTensor3 n1 n2 n3 k1 k2 v
-> TensList3 k1 k2 v -> TensList3 k1 k2 v
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2 v.
AbsTensor3 n1 n2 n3 k1 k2 v
-> TensList3 k1 k2 v -> TensList3 k1 k2 v
AppendTList3 AbsTensor3 n1 n2 n3 k1 k2 v
t1 TensList3 k1 k2 v
t2
(.&.+) (AppendTList3 AbsTensor3 n1 n2 n3 k1 k2 v
t1 TensList3 k1 k2 v
t1') TensList3 k1 k2 v
t2 = AbsTensor3 n1 n2 n3 k1 k2 v
-> TensList3 k1 k2 v -> TensList3 k1 k2 v
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2 v.
AbsTensor3 n1 n2 n3 k1 k2 v
-> TensList3 k1 k2 v -> TensList3 k1 k2 v
AppendTList3 AbsTensor3 n1 n2 n3 k1 k2 v
t1 (TensList3 k1 k2 v
t1' TensList3 k1 k2 v -> TensList3 k1 k2 v -> TensList3 k1 k2 v
forall k1 k2 v.
TensList3 k1 k2 v -> TensList3 k1 k2 v -> TensList3 k1 k2 v
.&.+ TensList3 k1 k2 v
t2)


infixr 5 .&&>

(.&&>) :: AbsTensor4 n1 n2 n3 n4 k1 k2 v -> TensList4 k1 k2 v -> TensList4 k1 k2 v
.&&> :: AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> TensList4 k1 k2 v -> TensList4 k1 k2 v
(.&&>) = AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> TensList4 k1 k2 v -> TensList4 k1 k2 v
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2 v.
AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> TensList4 k1 k2 v -> TensList4 k1 k2 v
AppendTList4

singletonTList4 :: AbsTensor4 n1 n2 n3 n4 k1 k2 v -> TensList4 k1 k2 v
singletonTList4 :: AbsTensor4 n1 n2 n3 n4 k1 k2 v -> TensList4 k1 k2 v
singletonTList4 AbsTensor4 n1 n2 n3 n4 k1 k2 v
t = AbsTensor4 n1 n2 n3 n4 k1 k2 v
t AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> TensList4 k1 k2 v -> TensList4 k1 k2 v
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2 v.
AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> TensList4 k1 k2 v -> TensList4 k1 k2 v
.&&> TensList4 k1 k2 v
forall k1 k2 v. TensList4 k1 k2 v
EmptyTList4

infixr 5 .&&+

(.&&+) :: TensList4 k1 k2 v -> TensList4 k1 k2 v -> TensList4 k1 k2 v
.&&+ :: TensList4 k1 k2 v -> TensList4 k1 k2 v -> TensList4 k1 k2 v
(.&&+) TensList4 k1 k2 v
EmptyTList4 TensList4 k1 k2 v
t1 = TensList4 k1 k2 v
t1
(.&&+) TensList4 k1 k2 v
t1 TensList4 k1 k2 v
EmptyTList4 = TensList4 k1 k2 v
t1
(.&&+) (AppendTList4 AbsTensor4 n1 n2 n3 n4 k1 k2 v
t1 TensList4 k1 k2 v
EmptyTList4) TensList4 k1 k2 v
t2 = AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> TensList4 k1 k2 v -> TensList4 k1 k2 v
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2 v.
AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> TensList4 k1 k2 v -> TensList4 k1 k2 v
AppendTList4 AbsTensor4 n1 n2 n3 n4 k1 k2 v
t1 TensList4 k1 k2 v
t2
(.&&+) (AppendTList4 AbsTensor4 n1 n2 n3 n4 k1 k2 v
t1 TensList4 k1 k2 v
t1') TensList4 k1 k2 v
t2 = AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> TensList4 k1 k2 v -> TensList4 k1 k2 v
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2 v.
AbsTensor4 n1 n2 n3 n4 k1 k2 v
-> TensList4 k1 k2 v -> TensList4 k1 k2 v
AppendTList4 AbsTensor4 n1 n2 n3 n4 k1 k2 v
t1 (TensList4 k1 k2 v
t1' TensList4 k1 k2 v -> TensList4 k1 k2 v -> TensList4 k1 k2 v
forall k1 k2 v.
TensList4 k1 k2 v -> TensList4 k1 k2 v -> TensList4 k1 k2 v
.&&+ TensList4 k1 k2 v
t2)


infixr 5 &..>

(&..>) :: AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> TensList5 k1 k2 k3 v -> TensList5 k1 k2 k3 v
&..> :: AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> TensList5 k1 k2 k3 v -> TensList5 k1 k2 k3 v
(&..>) = AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> TensList5 k1 k2 k3 v -> TensList5 k1 k2 k3 v
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       k1 k2 k3 v.
AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> TensList5 k1 k2 k3 v -> TensList5 k1 k2 k3 v
AppendTList5

singletonTList5 :: AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> TensList5 k1 k2 k3 v
singletonTList5 :: AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> TensList5 k1 k2 k3 v
singletonTList5 AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
t = AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
t AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> TensList5 k1 k2 k3 v -> TensList5 k1 k2 k3 v
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       k1 k2 k3 v.
AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> TensList5 k1 k2 k3 v -> TensList5 k1 k2 k3 v
&..> TensList5 k1 k2 k3 v
forall k1 k2 k3 v. TensList5 k1 k2 k3 v
EmptyTList5

infixr 5 &..+

(&..+) :: TensList5 k1 k2 k3 v -> TensList5 k1 k2 k3 v -> TensList5 k1 k2 k3 v
&..+ :: TensList5 k1 k2 k3 v
-> TensList5 k1 k2 k3 v -> TensList5 k1 k2 k3 v
(&..+) TensList5 k1 k2 k3 v
EmptyTList5 TensList5 k1 k2 k3 v
t1 = TensList5 k1 k2 k3 v
t1
(&..+) TensList5 k1 k2 k3 v
t1 TensList5 k1 k2 k3 v
EmptyTList5 = TensList5 k1 k2 k3 v
t1
(&..+) (AppendTList5 AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
t1 TensList5 k1 k2 k3 v
EmptyTList5) TensList5 k1 k2 k3 v
t2 = AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> TensList5 k1 k2 k3 v -> TensList5 k1 k2 k3 v
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       k1 k2 k3 v.
AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> TensList5 k1 k2 k3 v -> TensList5 k1 k2 k3 v
AppendTList5 AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
t1 TensList5 k1 k2 k3 v
t2
(&..+) (AppendTList5 AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
t1 TensList5 k1 k2 k3 v
t1') TensList5 k1 k2 k3 v
t2 = AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> TensList5 k1 k2 k3 v -> TensList5 k1 k2 k3 v
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       k1 k2 k3 v.
AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
-> TensList5 k1 k2 k3 v -> TensList5 k1 k2 k3 v
AppendTList5 AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v
t1 (TensList5 k1 k2 k3 v
t1' TensList5 k1 k2 k3 v
-> TensList5 k1 k2 k3 v -> TensList5 k1 k2 k3 v
forall k1 k2 k3 v.
TensList5 k1 k2 k3 v
-> TensList5 k1 k2 k3 v -> TensList5 k1 k2 k3 v
&..+ TensList5 k1 k2 k3 v
t2)


infixr 5 &.&>

(&.&>) :: AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> TensList6 k1 k2 k3 v -> TensList6 k1 k2 k3 v
&.&> :: AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> TensList6 k1 k2 k3 v -> TensList6 k1 k2 k3 v
(&.&>) = AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> TensList6 k1 k2 k3 v -> TensList6 k1 k2 k3 v
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) k1 k2 k3 v.
AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> TensList6 k1 k2 k3 v -> TensList6 k1 k2 k3 v
AppendTList6

singletonTList6 :: AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> TensList6 k1 k2 k3 v
singletonTList6 :: AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> TensList6 k1 k2 k3 v
singletonTList6 AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
t = AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
t AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> TensList6 k1 k2 k3 v -> TensList6 k1 k2 k3 v
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) k1 k2 k3 v.
AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> TensList6 k1 k2 k3 v -> TensList6 k1 k2 k3 v
&.&> TensList6 k1 k2 k3 v
forall k1 k2 k3 v. TensList6 k1 k2 k3 v
EmptyTList6

infixr 5 &.&+

(&.&+) :: TensList6 k1 k2 k3 v -> TensList6 k1 k2 k3 v -> TensList6 k1 k2 k3 v
&.&+ :: TensList6 k1 k2 k3 v
-> TensList6 k1 k2 k3 v -> TensList6 k1 k2 k3 v
(&.&+) TensList6 k1 k2 k3 v
EmptyTList6 TensList6 k1 k2 k3 v
t1 = TensList6 k1 k2 k3 v
t1
(&.&+) TensList6 k1 k2 k3 v
t1 TensList6 k1 k2 k3 v
EmptyTList6 = TensList6 k1 k2 k3 v
t1
(&.&+) (AppendTList6 AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
t1 TensList6 k1 k2 k3 v
EmptyTList6) TensList6 k1 k2 k3 v
t2 = AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> TensList6 k1 k2 k3 v -> TensList6 k1 k2 k3 v
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) k1 k2 k3 v.
AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> TensList6 k1 k2 k3 v -> TensList6 k1 k2 k3 v
AppendTList6 AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
t1 TensList6 k1 k2 k3 v
t2
(&.&+) (AppendTList6 AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
t1 TensList6 k1 k2 k3 v
t1') TensList6 k1 k2 k3 v
t2 = AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> TensList6 k1 k2 k3 v -> TensList6 k1 k2 k3 v
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) k1 k2 k3 v.
AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
-> TensList6 k1 k2 k3 v -> TensList6 k1 k2 k3 v
AppendTList6 AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v
t1 (TensList6 k1 k2 k3 v
t1' TensList6 k1 k2 k3 v
-> TensList6 k1 k2 k3 v -> TensList6 k1 k2 k3 v
forall k1 k2 k3 v.
TensList6 k1 k2 k3 v
-> TensList6 k1 k2 k3 v -> TensList6 k1 k2 k3 v
&.&+ TensList6 k1 k2 k3 v
t2)


infixr 5 &&.>

(&&.>) :: 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
&&.> :: 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
(&&.>) = 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
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4 v.
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
AppendTList7

singletonTList7 :: AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> TensList7 k1 k2 k3 k4 v
singletonTList7 :: AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
-> TensList7 k1 k2 k3 k4 v
singletonTList7 AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
t = AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
t 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
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4 v.
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
&&.> TensList7 k1 k2 k3 k4 v
forall k1 k2 k3 k4 v. TensList7 k1 k2 k3 k4 v
EmptyTList7

infixr 5 &&.+

(&&.+) :: TensList7 k1 k2 k3 k4 v -> TensList7 k1 k2 k3 k4 v -> TensList7 k1 k2 k3 k4 v
&&.+ :: TensList7 k1 k2 k3 k4 v
-> TensList7 k1 k2 k3 k4 v -> TensList7 k1 k2 k3 k4 v
(&&.+) TensList7 k1 k2 k3 k4 v
EmptyTList7 TensList7 k1 k2 k3 k4 v
t1 = TensList7 k1 k2 k3 k4 v
t1
(&&.+) TensList7 k1 k2 k3 k4 v
t1 TensList7 k1 k2 k3 k4 v
EmptyTList7 = TensList7 k1 k2 k3 k4 v
t1
(&&.+) (AppendTList7 AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
t1 TensList7 k1 k2 k3 k4 v
EmptyTList7) TensList7 k1 k2 k3 k4 v
t2 = 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
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4 v.
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
AppendTList7 AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
t1 TensList7 k1 k2 k3 k4 v
t2
(&&.+) (AppendTList7 AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
t1 TensList7 k1 k2 k3 k4 v
t1') TensList7 k1 k2 k3 k4 v
t2 = 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
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4 v.
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
AppendTList7 AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
t1 (TensList7 k1 k2 k3 k4 v
t1' TensList7 k1 k2 k3 k4 v
-> TensList7 k1 k2 k3 k4 v -> TensList7 k1 k2 k3 k4 v
forall k1 k2 k3 k4 v.
TensList7 k1 k2 k3 k4 v
-> TensList7 k1 k2 k3 k4 v -> TensList7 k1 k2 k3 k4 v
&&.+ TensList7 k1 k2 k3 k4 v
t2)


infixr 5 &&&>

(&&&>) :: 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
&&&> :: 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
(&&&>) = 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
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) (n8 :: Nat) k1 k2 k3 k4 v.
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
AppendTList8

singletonTList8 :: AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> TensList8 k1 k2 k3 k4 v
singletonTList8 :: AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
-> TensList8 k1 k2 k3 k4 v
singletonTList8 AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
t = AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
t 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
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) (n8 :: Nat) k1 k2 k3 k4 v.
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
&&&> TensList8 k1 k2 k3 k4 v
forall k1 k2 k3 k4 v. TensList8 k1 k2 k3 k4 v
EmptyTList8

infixr 5 &&&+

(&&&+) :: TensList8 k1 k2 k3 k4 v -> TensList8 k1 k2 k3 k4 v -> TensList8 k1 k2 k3 k4 v
&&&+ :: TensList8 k1 k2 k3 k4 v
-> TensList8 k1 k2 k3 k4 v -> TensList8 k1 k2 k3 k4 v
(&&&+) TensList8 k1 k2 k3 k4 v
EmptyTList8 TensList8 k1 k2 k3 k4 v
t1 = TensList8 k1 k2 k3 k4 v
t1
(&&&+) TensList8 k1 k2 k3 k4 v
t1 TensList8 k1 k2 k3 k4 v
EmptyTList8 = TensList8 k1 k2 k3 k4 v
t1
(&&&+) (AppendTList8 AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
t1 TensList8 k1 k2 k3 k4 v
EmptyTList8) TensList8 k1 k2 k3 k4 v
t2 = 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
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) (n8 :: Nat) k1 k2 k3 k4 v.
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
AppendTList8 AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
t1 TensList8 k1 k2 k3 k4 v
t2
(&&&+) (AppendTList8 AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
t1 TensList8 k1 k2 k3 k4 v
t1') TensList8 k1 k2 k3 k4 v
t2 = 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
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) (n8 :: Nat) k1 k2 k3 k4 v.
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
AppendTList8 AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
t1 (TensList8 k1 k2 k3 k4 v
t1' TensList8 k1 k2 k3 k4 v
-> TensList8 k1 k2 k3 k4 v -> TensList8 k1 k2 k3 k4 v
forall k1 k2 k3 k4 v.
TensList8 k1 k2 k3 k4 v
-> TensList8 k1 k2 k3 k4 v -> TensList8 k1 k2 k3 k4 v
&&&+ TensList8 k1 k2 k3 k4 v
t2)


--collect data of heterogeneous tensor list in one sparse matrix assocs list
--intended for evaluating tensorial equations: the values are only collected up to overall factors

collectMatList :: [[(Int, a)]] -> [((Int, Int), a)]
collectMatList :: [[(Int, a)]] -> [((Int, Int), a)]
collectMatList [[(Int, a)]]
matList = [((Int, Int), a)]
l
    where
        -- l2 = nubBy (\(a,_) (b,_) -> a == b) $ map normalize matList
        -- l = map (\(x,y) -> map (\(a,b) -> (a,b*y)) x) l2
        l :: [((Int, Int), a)]
l = [[((Int, Int), a)]] -> [((Int, Int), a)]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[((Int, Int), a)]] -> [((Int, Int), a)])
-> [[((Int, Int), a)]] -> [((Int, Int), a)]
forall a b. (a -> b) -> a -> b
$ ([(Int, a)] -> Int -> [((Int, Int), a)])
-> [[(Int, a)]] -> [Int] -> [[((Int, Int), a)]]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith (\[(Int, a)]
r Int
z -> ((Int, a) -> ((Int, Int), a)) -> [(Int, a)] -> [((Int, Int), a)]
forall a b. (a -> b) -> [a] -> [b]
map (\(Int
x,a
y) -> ((Int
z, Int
x), a
y)) [(Int, a)]
r) [[(Int, a)]]
matList [Int
1..]

toMatListT1 :: (TIndex k1, TAdd a) => TensList1 k1 (AnsVar a) -> [((Int,Int),a)]
toMatListT1 :: TensList1 k1 (AnsVar a) -> [((Int, Int), a)]
toMatListT1 TensList1 k1 (AnsVar a)
t = [[(Int, a)]] -> [((Int, Int), a)]
forall a. [[(Int, a)]] -> [((Int, Int), a)]
collectMatList [[(Int, a)]]
matList
    where
        matList :: [[(Int, a)]]
matList = [[[(Int, a)]]] -> [[(Int, a)]]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[[(Int, a)]]] -> [[(Int, a)]]) -> [[[(Int, a)]]] -> [[(Int, a)]]
forall a b. (a -> b) -> a -> b
$ (forall (n1 :: Nat). AbsTensor1 n1 k1 (AnsVar a) -> [[(Int, a)]])
-> TensList1 k1 (AnsVar a) -> [[[(Int, a)]]]
forall k1 v b.
(forall (n1 :: Nat). AbsTensor1 n1 k1 v -> b)
-> TensList1 k1 v -> [b]
mapTensList1 forall k1 a (n1 :: Nat).
(TIndex k1, TAdd a) =>
AbsTensor1 n1 k1 (AnsVar a) -> [[(Int, a)]]
forall (n1 :: Nat). AbsTensor1 n1 k1 (AnsVar a) -> [[(Int, a)]]
toMatList1' TensList1 k1 (AnsVar a)
t

toMatListT2 :: (TIndex k1, TAdd a) => TensList2 k1 (AnsVar a) -> [((Int,Int),a)]
toMatListT2 :: TensList2 k1 (AnsVar a) -> [((Int, Int), a)]
toMatListT2 TensList2 k1 (AnsVar a)
t = [[(Int, a)]] -> [((Int, Int), a)]
forall a. [[(Int, a)]] -> [((Int, Int), a)]
collectMatList [[(Int, a)]]
matList
    where
        matList :: [[(Int, a)]]
matList = [[[(Int, a)]]] -> [[(Int, a)]]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[[(Int, a)]]] -> [[(Int, a)]]) -> [[[(Int, a)]]] -> [[(Int, a)]]
forall a b. (a -> b) -> a -> b
$ (forall (n1 :: Nat) (n2 :: Nat).
 AbsTensor2 n1 n2 k1 (AnsVar a) -> [[(Int, a)]])
-> TensList2 k1 (AnsVar a) -> [[[(Int, a)]]]
forall k1 v b.
(forall (n1 :: Nat) (n2 :: Nat). AbsTensor2 n1 n2 k1 v -> b)
-> TensList2 k1 v -> [b]
mapTensList2 forall k1 a (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd a) =>
AbsTensor2 n1 n2 k1 (AnsVar a) -> [[(Int, a)]]
forall (n1 :: Nat) (n2 :: Nat).
AbsTensor2 n1 n2 k1 (AnsVar a) -> [[(Int, a)]]
toMatList2' TensList2 k1 (AnsVar a)
t

toMatListT3 :: (TIndex k1, TIndex k2, TAdd a) => TensList3 k1 k2 (AnsVar a) -> [((Int,Int),a)]
toMatListT3 :: TensList3 k1 k2 (AnsVar a) -> [((Int, Int), a)]
toMatListT3 TensList3 k1 k2 (AnsVar a)
t = [[(Int, a)]] -> [((Int, Int), a)]
forall a. [[(Int, a)]] -> [((Int, Int), a)]
collectMatList [[(Int, a)]]
matList
    where
        matList :: [[(Int, a)]]
matList = [[[(Int, a)]]] -> [[(Int, a)]]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[[(Int, a)]]] -> [[(Int, a)]]) -> [[[(Int, a)]]] -> [[(Int, a)]]
forall a b. (a -> b) -> a -> b
$ (forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat).
 AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a) -> [[(Int, a)]])
-> TensList3 k1 k2 (AnsVar a) -> [[[(Int, a)]]]
forall k1 k2 v b.
(forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat).
 AbsTensor3 n1 n2 n3 k1 k2 v -> b)
-> TensList3 k1 k2 v -> [b]
mapTensList3 forall k1 k2 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat).
(TIndex k1, TIndex k2, TAdd a) =>
AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a) -> [[(Int, a)]]
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat).
AbsTensor3 n1 n2 n3 k1 k2 (AnsVar a) -> [[(Int, a)]]
toMatList3' TensList3 k1 k2 (AnsVar a)
t

toMatListT4 :: (TIndex k1, TIndex k2, TAdd a) => TensList4 k1 k2 (AnsVar a) -> [((Int,Int),a)]
toMatListT4 :: TensList4 k1 k2 (AnsVar a) -> [((Int, Int), a)]
toMatListT4 TensList4 k1 k2 (AnsVar a)
t = [[(Int, a)]] -> [((Int, Int), a)]
forall a. [[(Int, a)]] -> [((Int, Int), a)]
collectMatList [[(Int, a)]]
matList
    where
        matList :: [[(Int, a)]]
matList = [[[(Int, a)]]] -> [[(Int, a)]]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[[(Int, a)]]] -> [[(Int, a)]]) -> [[[(Int, a)]]] -> [[(Int, a)]]
forall a b. (a -> b) -> a -> b
$ (forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat).
 AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a) -> [[(Int, a)]])
-> TensList4 k1 k2 (AnsVar a) -> [[[(Int, a)]]]
forall k1 k2 v b.
(forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat).
 AbsTensor4 n1 n2 n3 n4 k1 k2 v -> b)
-> TensList4 k1 k2 v -> [b]
mapTensList4 forall k1 k2 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat).
(TIndex k1, TIndex k2, TAdd a) =>
AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a) -> [[(Int, a)]]
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat).
AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar a) -> [[(Int, a)]]
toMatList4' TensList4 k1 k2 (AnsVar a)
t

toMatListT5 :: (TIndex k1, TIndex k2, TIndex k3, TAdd a) => TensList5 k1 k2 k3 (AnsVar a) -> [((Int,Int),a)]
toMatListT5 :: TensList5 k1 k2 k3 (AnsVar a) -> [((Int, Int), a)]
toMatListT5 TensList5 k1 k2 k3 (AnsVar a)
t = [[(Int, a)]] -> [((Int, Int), a)]
forall a. [[(Int, a)]] -> [((Int, Int), a)]
collectMatList [[(Int, a)]]
matList
    where
        matList :: [[(Int, a)]]
matList = [[[(Int, a)]]] -> [[(Int, a)]]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[[(Int, a)]]] -> [[(Int, a)]]) -> [[[(Int, a)]]] -> [[(Int, a)]]
forall a b. (a -> b) -> a -> b
$ (forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
        (n5 :: Nat).
 AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a) -> [[(Int, a)]])
-> TensList5 k1 k2 k3 (AnsVar a) -> [[[(Int, a)]]]
forall k1 k2 k3 v b.
(forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
        (n5 :: Nat).
 AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> b)
-> TensList5 k1 k2 k3 v -> [b]
mapTensList5 forall k1 k2 k3 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat).
(TIndex k1, TIndex k2, TIndex k3, TAdd a) =>
AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a) -> [[(Int, a)]]
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat).
AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar a) -> [[(Int, a)]]
toMatList5' TensList5 k1 k2 k3 (AnsVar a)
t

toMatListT6 :: (TIndex k1, TIndex k2, TIndex k3, TAdd a) => TensList6 k1 k2 k3 (AnsVar a) -> [((Int,Int),a)]
toMatListT6 :: TensList6 k1 k2 k3 (AnsVar a) -> [((Int, Int), a)]
toMatListT6 TensList6 k1 k2 k3 (AnsVar a)
t = [[(Int, a)]] -> [((Int, Int), a)]
forall a. [[(Int, a)]] -> [((Int, Int), a)]
collectMatList [[(Int, a)]]
matList
    where
        matList :: [[(Int, a)]]
matList = [[[(Int, a)]]] -> [[(Int, a)]]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[[(Int, a)]]] -> [[(Int, a)]]) -> [[[(Int, a)]]] -> [[(Int, a)]]
forall a b. (a -> b) -> a -> b
$ (forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
        (n6 :: Nat).
 AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a) -> [[(Int, a)]])
-> TensList6 k1 k2 k3 (AnsVar a) -> [[[(Int, a)]]]
forall k1 k2 k3 v b.
(forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
        (n6 :: Nat).
 AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> b)
-> TensList6 k1 k2 k3 v -> [b]
mapTensList6 forall k1 k2 k3 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat)
       (n5 :: Nat) (n6 :: Nat).
(TIndex k1, TIndex k2, TIndex k3, TAdd a) =>
AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a) -> [[(Int, a)]]
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat).
AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar a) -> [[(Int, a)]]
toMatList6' TensList6 k1 k2 k3 (AnsVar a)
t

toMatListT7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd a) => TensList7 k1 k2 k3 k4 (AnsVar a) -> [((Int,Int),a)]
toMatListT7 :: TensList7 k1 k2 k3 k4 (AnsVar a) -> [((Int, Int), a)]
toMatListT7 TensList7 k1 k2 k3 k4 (AnsVar a)
t = [[(Int, a)]] -> [((Int, Int), a)]
forall a. [[(Int, a)]] -> [((Int, Int), a)]
collectMatList [[(Int, a)]]
matList
    where
        matList :: [[(Int, a)]]
matList = [[[(Int, a)]]] -> [[(Int, a)]]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[[(Int, a)]]] -> [[(Int, a)]]) -> [[[(Int, a)]]] -> [[(Int, a)]]
forall a b. (a -> b) -> a -> b
$ (forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
        (n6 :: Nat) (n7 :: Nat).
 AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar a)
 -> [[(Int, a)]])
-> TensList7 k1 k2 k3 k4 (AnsVar a) -> [[[(Int, a)]]]
forall k1 k2 k3 k4 v b.
(forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
        (n6 :: Nat) (n7 :: Nat).
 AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v -> b)
-> TensList7 k1 k2 k3 k4 v -> [b]
mapTensList7 forall k1 k2 k3 k4 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat)
       (n4 :: Nat) (n5 :: Nat) (n6 :: Nat) (n7 :: Nat).
(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, a)]]
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat).
AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar a)
-> [[(Int, a)]]
toMatList7' TensList7 k1 k2 k3 k4 (AnsVar a)
t

toMatListT8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd a) => TensList8 k1 k2 k3 k4 (AnsVar a) -> [((Int,Int),a)]
toMatListT8 :: TensList8 k1 k2 k3 k4 (AnsVar a) -> [((Int, Int), a)]
toMatListT8 TensList8 k1 k2 k3 k4 (AnsVar a)
t = [[(Int, a)]] -> [((Int, Int), a)]
forall a. [[(Int, a)]] -> [((Int, Int), a)]
collectMatList [[(Int, a)]]
matList
    where
        matList :: [[(Int, a)]]
matList = [[[(Int, a)]]] -> [[(Int, a)]]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[[(Int, a)]]] -> [[(Int, a)]]) -> [[[(Int, a)]]] -> [[(Int, a)]]
forall a b. (a -> b) -> a -> b
$ (forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
        (n6 :: Nat) (n7 :: Nat) (n8 :: Nat).
 AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar a)
 -> [[(Int, a)]])
-> TensList8 k1 k2 k3 k4 (AnsVar a) -> [[[(Int, a)]]]
forall k1 k2 k3 k4 v b.
(forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
        (n6 :: Nat) (n7 :: Nat) (n8 :: Nat).
 AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v -> b)
-> TensList8 k1 k2 k3 k4 v -> [b]
mapTensList8 forall k1 k2 k3 k4 a (n1 :: Nat) (n2 :: Nat) (n3 :: Nat)
       (n4 :: Nat) (n5 :: Nat) (n6 :: Nat) (n7 :: Nat) (n8 :: Nat).
(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, a)]]
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) (n8 :: Nat).
AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar a)
-> [[(Int, a)]]
toMatList8' TensList8 k1 k2 k3 k4 (AnsVar a)
t


--convert to hmatrix format for using LA subroutines

dims :: [((Int, Int), a)] -> (Int, Int)
dims :: [((Int, Int), a)] -> (Int, Int)
dims [((Int, Int), a)]
xs = (Int
rows, Int
cols)
    where
        rows :: Int
rows = [Int] -> Int
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
maximum ([Int] -> Int) -> [Int] -> Int
forall a b. (a -> b) -> a -> b
$ (((Int, Int), a) -> Int) -> [((Int, Int), a)] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map ((Int, Int) -> Int
forall a b. (a, b) -> a
fst((Int, Int) -> Int)
-> (((Int, Int), a) -> (Int, Int)) -> ((Int, Int), a) -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
.((Int, Int), a) -> (Int, Int)
forall a b. (a, b) -> a
fst) [((Int, Int), a)]
xs
        cols :: Int
cols = [Int] -> Int
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
maximum ([Int] -> Int) -> [Int] -> Int
forall a b. (a -> b) -> a -> b
$ (((Int, Int), a) -> Int) -> [((Int, Int), a)] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map ((Int, Int) -> Int
forall a b. (a, b) -> b
snd((Int, Int) -> Int)
-> (((Int, Int), a) -> (Int, Int)) -> ((Int, Int), a) -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
.((Int, Int), a) -> (Int, Int)
forall a b. (a, b) -> a
fst) [((Int, Int), a)]
xs

assocsToMatrix :: Real a => [((Int, Int), SField a)] -> HM.Matrix Double
assocsToMatrix :: [((Int, Int), SField a)] -> Matrix Double
assocsToMatrix [] = (Int
1 Int -> Int -> [Double] -> Matrix Double
forall a. Storable a => Int -> Int -> [a] -> Matrix a
HM.>< Int
1) [Double
0]
assocsToMatrix [((Int, Int), SField a)]
assocs = IndexOf Matrix
-> Double -> [(IndexOf Matrix, Double)] -> Matrix Double
forall (c :: * -> *) e.
Container c e =>
IndexOf c -> e -> [(IndexOf c, e)] -> c e
HM.assoc (Int
rows, Int
cols) Double
0 [((Int, Int), Double)]
[(IndexOf Matrix, Double)]
els
    where
        (Int
rows, Int
cols) = [((Int, Int), SField a)] -> (Int, Int)
forall a. [((Int, Int), a)] -> (Int, Int)
dims [((Int, Int), SField a)]
assocs
        els :: [((Int, Int), Double)]
els          = (((Int, Int), SField a) -> ((Int, Int), Double))
-> [((Int, Int), SField a)] -> [((Int, Int), Double)]
forall a b. (a -> b) -> [a] -> [b]
map (\((Int
x, Int
y), SField a
z) -> ((Int
xInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1, Int
yInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1), Rational -> Double
forall a. Fractional a => Rational -> a
fromRational (Rational -> Double) -> Rational -> Double
forall a b. (a -> b) -> a -> b
$ a -> Rational
forall a. Real a => a -> Rational
toRational a
z)) [((Int, Int), SField a)]
assocs

toMatrixT1 :: (TIndex k1, Real a) => TensList1 k1 (AnsVar (SField a)) -> HM.Matrix Double
toMatrixT1 :: TensList1 k1 (AnsVar (SField a)) -> Matrix Double
toMatrixT1 = [((Int, Int), SField a)] -> Matrix Double
forall a. Real a => [((Int, Int), SField a)] -> Matrix Double
assocsToMatrix ([((Int, Int), SField a)] -> Matrix Double)
-> (TensList1 k1 (AnsVar (SField a)) -> [((Int, Int), SField a)])
-> TensList1 k1 (AnsVar (SField a))
-> Matrix Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TensList1 k1 (AnsVar (SField a)) -> [((Int, Int), SField a)]
forall k1 a.
(TIndex k1, TAdd a) =>
TensList1 k1 (AnsVar a) -> [((Int, Int), a)]
toMatListT1

toMatrixT2 :: (TIndex k1, Real a) => TensList2 k1 (AnsVar (SField a)) -> HM.Matrix Double
toMatrixT2 :: TensList2 k1 (AnsVar (SField a)) -> Matrix Double
toMatrixT2 = [((Int, Int), SField a)] -> Matrix Double
forall a. Real a => [((Int, Int), SField a)] -> Matrix Double
assocsToMatrix ([((Int, Int), SField a)] -> Matrix Double)
-> (TensList2 k1 (AnsVar (SField a)) -> [((Int, Int), SField a)])
-> TensList2 k1 (AnsVar (SField a))
-> Matrix Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TensList2 k1 (AnsVar (SField a)) -> [((Int, Int), SField a)]
forall k1 a.
(TIndex k1, TAdd a) =>
TensList2 k1 (AnsVar a) -> [((Int, Int), a)]
toMatListT2

toMatrixT3 :: (TIndex k1, TIndex k2, Real a) => TensList3 k1 k2 (AnsVar (SField a)) -> HM.Matrix Double
toMatrixT3 :: TensList3 k1 k2 (AnsVar (SField a)) -> Matrix Double
toMatrixT3 = [((Int, Int), SField a)] -> Matrix Double
forall a. Real a => [((Int, Int), SField a)] -> Matrix Double
assocsToMatrix ([((Int, Int), SField a)] -> Matrix Double)
-> (TensList3 k1 k2 (AnsVar (SField a))
    -> [((Int, Int), SField a)])
-> TensList3 k1 k2 (AnsVar (SField a))
-> Matrix Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TensList3 k1 k2 (AnsVar (SField a)) -> [((Int, Int), SField a)]
forall k1 k2 a.
(TIndex k1, TIndex k2, TAdd a) =>
TensList3 k1 k2 (AnsVar a) -> [((Int, Int), a)]
toMatListT3

toMatrixT4 :: (TIndex k1, TIndex k2, Real a) => TensList4 k1 k2 (AnsVar (SField a)) -> HM.Matrix Double
toMatrixT4 :: TensList4 k1 k2 (AnsVar (SField a)) -> Matrix Double
toMatrixT4 = [((Int, Int), SField a)] -> Matrix Double
forall a. Real a => [((Int, Int), SField a)] -> Matrix Double
assocsToMatrix ([((Int, Int), SField a)] -> Matrix Double)
-> (TensList4 k1 k2 (AnsVar (SField a))
    -> [((Int, Int), SField a)])
-> TensList4 k1 k2 (AnsVar (SField a))
-> Matrix Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TensList4 k1 k2 (AnsVar (SField a)) -> [((Int, Int), SField a)]
forall k1 k2 a.
(TIndex k1, TIndex k2, TAdd a) =>
TensList4 k1 k2 (AnsVar a) -> [((Int, Int), a)]
toMatListT4

toMatrixT5 :: (TIndex k1, TIndex k2, TIndex k3, Real a) => TensList5 k1 k2 k3 (AnsVar (SField a)) -> HM.Matrix Double
toMatrixT5 :: TensList5 k1 k2 k3 (AnsVar (SField a)) -> Matrix Double
toMatrixT5 = [((Int, Int), SField a)] -> Matrix Double
forall a. Real a => [((Int, Int), SField a)] -> Matrix Double
assocsToMatrix ([((Int, Int), SField a)] -> Matrix Double)
-> (TensList5 k1 k2 k3 (AnsVar (SField a))
    -> [((Int, Int), SField a)])
-> TensList5 k1 k2 k3 (AnsVar (SField a))
-> Matrix Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TensList5 k1 k2 k3 (AnsVar (SField a)) -> [((Int, Int), SField a)]
forall k1 k2 k3 a.
(TIndex k1, TIndex k2, TIndex k3, TAdd a) =>
TensList5 k1 k2 k3 (AnsVar a) -> [((Int, Int), a)]
toMatListT5

toMatrixT6 :: (TIndex k1, TIndex k2, TIndex k3, Real a) => TensList6 k1 k2 k3 (AnsVar (SField a)) -> HM.Matrix Double
toMatrixT6 :: TensList6 k1 k2 k3 (AnsVar (SField a)) -> Matrix Double
toMatrixT6 = [((Int, Int), SField a)] -> Matrix Double
forall a. Real a => [((Int, Int), SField a)] -> Matrix Double
assocsToMatrix ([((Int, Int), SField a)] -> Matrix Double)
-> (TensList6 k1 k2 k3 (AnsVar (SField a))
    -> [((Int, Int), SField a)])
-> TensList6 k1 k2 k3 (AnsVar (SField a))
-> Matrix Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TensList6 k1 k2 k3 (AnsVar (SField a)) -> [((Int, Int), SField a)]
forall k1 k2 k3 a.
(TIndex k1, TIndex k2, TIndex k3, TAdd a) =>
TensList6 k1 k2 k3 (AnsVar a) -> [((Int, Int), a)]
toMatListT6

toMatrixT7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, Real a) => TensList7 k1 k2 k3 k4 (AnsVar (SField a)) -> HM.Matrix Double
toMatrixT7 :: TensList7 k1 k2 k3 k4 (AnsVar (SField a)) -> Matrix Double
toMatrixT7 = [((Int, Int), SField a)] -> Matrix Double
forall a. Real a => [((Int, Int), SField a)] -> Matrix Double
assocsToMatrix ([((Int, Int), SField a)] -> Matrix Double)
-> (TensList7 k1 k2 k3 k4 (AnsVar (SField a))
    -> [((Int, Int), SField a)])
-> TensList7 k1 k2 k3 k4 (AnsVar (SField a))
-> Matrix Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TensList7 k1 k2 k3 k4 (AnsVar (SField a))
-> [((Int, Int), SField a)]
forall k1 k2 k3 k4 a.
(TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd a) =>
TensList7 k1 k2 k3 k4 (AnsVar a) -> [((Int, Int), a)]
toMatListT7

toMatrixT8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, Real a) => TensList8 k1 k2 k3 k4 (AnsVar (SField a)) -> HM.Matrix Double
toMatrixT8 :: TensList8 k1 k2 k3 k4 (AnsVar (SField a)) -> Matrix Double
toMatrixT8 = [((Int, Int), SField a)] -> Matrix Double
forall a. Real a => [((Int, Int), SField a)] -> Matrix Double
assocsToMatrix ([((Int, Int), SField a)] -> Matrix Double)
-> (TensList8 k1 k2 k3 k4 (AnsVar (SField a))
    -> [((Int, Int), SField a)])
-> TensList8 k1 k2 k3 k4 (AnsVar (SField a))
-> Matrix Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TensList8 k1 k2 k3 k4 (AnsVar (SField a))
-> [((Int, Int), SField a)]
forall k1 k2 k3 k4 a.
(TIndex k1, TIndex k2, TIndex k3, TIndex k4, TAdd a) =>
TensList8 k1 k2 k3 k4 (AnsVar a) -> [((Int, Int), a)]
toMatListT8

--rank of the tensor can be computed with rank Sol.FullPivLU or Sol.JakobiSVD

tensorRank1' :: (TIndex k1, Real a, Real a) => AbsTensor1 n1 k1 (AnsVar (SField a)) -> Int
tensorRank1' :: AbsTensor1 n1 k1 (AnsVar (SField a)) -> Int
tensorRank1' AbsTensor1 n1 k1 (AnsVar (SField a))
t = Matrix Double -> Int
forall t. Field t => Matrix t -> Int
rank (Matrix Double -> Int) -> Matrix Double -> Int
forall a b. (a -> b) -> a -> b
$ TensList1 k1 (AnsVar (SField a)) -> Matrix Double
forall k1 a.
(TIndex k1, Real a) =>
TensList1 k1 (AnsVar (SField a)) -> Matrix Double
toMatrixT1 (AbsTensor1 n1 k1 (AnsVar (SField a))
-> TensList1 k1 (AnsVar (SField a))
forall (n1 :: Nat) k1 v. AbsTensor1 n1 k1 v -> TensList1 k1 v
singletonTList1 AbsTensor1 n1 k1 (AnsVar (SField a))
t)

tensorRank1 :: (TIndex k1, Real a) => TensList1 k1 (AnsVar (SField a)) -> Int
tensorRank1 :: TensList1 k1 (AnsVar (SField a)) -> Int
tensorRank1 TensList1 k1 (AnsVar (SField a))
t = Matrix Double -> Int
forall t. Field t => Matrix t -> Int
rank (Matrix Double -> Int) -> Matrix Double -> Int
forall a b. (a -> b) -> a -> b
$ TensList1 k1 (AnsVar (SField a)) -> Matrix Double
forall k1 a.
(TIndex k1, Real a) =>
TensList1 k1 (AnsVar (SField a)) -> Matrix Double
toMatrixT1 TensList1 k1 (AnsVar (SField a))
t


tensorRank2' :: (TIndex k1, Real a) => AbsTensor2 n1 n2 k1 (AnsVar (SField a)) -> Int
tensorRank2' :: AbsTensor2 n1 n2 k1 (AnsVar (SField a)) -> Int
tensorRank2' AbsTensor2 n1 n2 k1 (AnsVar (SField a))
t = Matrix Double -> Int
forall t. Field t => Matrix t -> Int
rank (Matrix Double -> Int) -> Matrix Double -> Int
forall a b. (a -> b) -> a -> b
$ TensList2 k1 (AnsVar (SField a)) -> Matrix Double
forall k1 a.
(TIndex k1, Real a) =>
TensList2 k1 (AnsVar (SField a)) -> Matrix Double
toMatrixT2 (AbsTensor2 n1 n2 k1 (AnsVar (SField a))
-> TensList2 k1 (AnsVar (SField a))
forall (n1 :: Nat) (n2 :: Nat) k1 v.
AbsTensor2 n1 n2 k1 v -> TensList2 k1 v
singletonTList2 AbsTensor2 n1 n2 k1 (AnsVar (SField a))
t)

tensorRank2 :: (TIndex k1, Real a) => TensList2 k1 (AnsVar (SField a)) -> Int
tensorRank2 :: TensList2 k1 (AnsVar (SField a)) -> Int
tensorRank2 TensList2 k1 (AnsVar (SField a))
t = Matrix Double -> Int
forall t. Field t => Matrix t -> Int
rank (Matrix Double -> Int) -> Matrix Double -> Int
forall a b. (a -> b) -> a -> b
$ TensList2 k1 (AnsVar (SField a)) -> Matrix Double
forall k1 a.
(TIndex k1, Real a) =>
TensList2 k1 (AnsVar (SField a)) -> Matrix Double
toMatrixT2 TensList2 k1 (AnsVar (SField a))
t


tensorRank3' :: (TIndex k1, TIndex k2, Real a) => AbsTensor3 n1 n2 n3 k1 k2 (AnsVar (SField a)) -> Int
tensorRank3' :: AbsTensor3 n1 n2 n3 k1 k2 (AnsVar (SField a)) -> Int
tensorRank3' AbsTensor3 n1 n2 n3 k1 k2 (AnsVar (SField a))
t = Matrix Double -> Int
forall t. Field t => Matrix t -> Int
rank (Matrix Double -> Int) -> Matrix Double -> Int
forall a b. (a -> b) -> a -> b
$ TensList3 k1 k2 (AnsVar (SField a)) -> Matrix Double
forall k1 k2 a.
(TIndex k1, TIndex k2, Real a) =>
TensList3 k1 k2 (AnsVar (SField a)) -> Matrix Double
toMatrixT3 (AbsTensor3 n1 n2 n3 k1 k2 (AnsVar (SField a))
-> TensList3 k1 k2 (AnsVar (SField a))
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) k1 k2 v.
AbsTensor3 n1 n2 n3 k1 k2 v -> TensList3 k1 k2 v
singletonTList3 AbsTensor3 n1 n2 n3 k1 k2 (AnsVar (SField a))
t)

tensorRank3 :: (TIndex k1, TIndex k2, Real a) =>  TensList3 k1 k2 (AnsVar (SField a)) -> Int
tensorRank3 :: TensList3 k1 k2 (AnsVar (SField a)) -> Int
tensorRank3 TensList3 k1 k2 (AnsVar (SField a))
t = Matrix Double -> Int
forall t. Field t => Matrix t -> Int
rank (Matrix Double -> Int) -> Matrix Double -> Int
forall a b. (a -> b) -> a -> b
$ TensList3 k1 k2 (AnsVar (SField a)) -> Matrix Double
forall k1 k2 a.
(TIndex k1, TIndex k2, Real a) =>
TensList3 k1 k2 (AnsVar (SField a)) -> Matrix Double
toMatrixT3 TensList3 k1 k2 (AnsVar (SField a))
t


tensorRank4' :: (TIndex k1, TIndex k2, Real a) =>  AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar (SField a)) -> Int
tensorRank4' :: AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar (SField a)) -> Int
tensorRank4' AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar (SField a))
t = Matrix Double -> Int
forall t. Field t => Matrix t -> Int
rank (Matrix Double -> Int) -> Matrix Double -> Int
forall a b. (a -> b) -> a -> b
$ TensList4 k1 k2 (AnsVar (SField a)) -> Matrix Double
forall k1 k2 a.
(TIndex k1, TIndex k2, Real a) =>
TensList4 k1 k2 (AnsVar (SField a)) -> Matrix Double
toMatrixT4 (AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar (SField a))
-> TensList4 k1 k2 (AnsVar (SField a))
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) k1 k2 v.
AbsTensor4 n1 n2 n3 n4 k1 k2 v -> TensList4 k1 k2 v
singletonTList4 AbsTensor4 n1 n2 n3 n4 k1 k2 (AnsVar (SField a))
t)

tensorRank4 :: (TIndex k1, TIndex k2, Real a) =>  TensList4 k1 k2 (AnsVar (SField a)) -> Int
tensorRank4 :: TensList4 k1 k2 (AnsVar (SField a)) -> Int
tensorRank4 TensList4 k1 k2 (AnsVar (SField a))
t = Matrix Double -> Int
forall t. Field t => Matrix t -> Int
rank (Matrix Double -> Int) -> Matrix Double -> Int
forall a b. (a -> b) -> a -> b
$ TensList4 k1 k2 (AnsVar (SField a)) -> Matrix Double
forall k1 k2 a.
(TIndex k1, TIndex k2, Real a) =>
TensList4 k1 k2 (AnsVar (SField a)) -> Matrix Double
toMatrixT4 TensList4 k1 k2 (AnsVar (SField a))
t


tensorRank5' :: (TIndex k1, TIndex k2, TIndex k3, Real a) =>  AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar (SField a)) -> Int
tensorRank5' :: AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar (SField a)) -> Int
tensorRank5' AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar (SField a))
t = Matrix Double -> Int
forall t. Field t => Matrix t -> Int
rank (Matrix Double -> Int) -> Matrix Double -> Int
forall a b. (a -> b) -> a -> b
$ TensList5 k1 k2 k3 (AnsVar (SField a)) -> Matrix Double
forall k1 k2 k3 a.
(TIndex k1, TIndex k2, TIndex k3, Real a) =>
TensList5 k1 k2 k3 (AnsVar (SField a)) -> Matrix Double
toMatrixT5 (AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar (SField a))
-> TensList5 k1 k2 k3 (AnsVar (SField a))
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       k1 k2 k3 v.
AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 v -> TensList5 k1 k2 k3 v
singletonTList5 AbsTensor5 n1 n2 n3 n4 n5 k1 k2 k3 (AnsVar (SField a))
t)

tensorRank5 :: (TIndex k1, TIndex k2, TIndex k3, Real a) => TensList5 k1 k2 k3 (AnsVar (SField a)) -> Int
tensorRank5 :: TensList5 k1 k2 k3 (AnsVar (SField a)) -> Int
tensorRank5 TensList5 k1 k2 k3 (AnsVar (SField a))
t = Matrix Double -> Int
forall t. Field t => Matrix t -> Int
rank (Matrix Double -> Int) -> Matrix Double -> Int
forall a b. (a -> b) -> a -> b
$ TensList5 k1 k2 k3 (AnsVar (SField a)) -> Matrix Double
forall k1 k2 k3 a.
(TIndex k1, TIndex k2, TIndex k3, Real a) =>
TensList5 k1 k2 k3 (AnsVar (SField a)) -> Matrix Double
toMatrixT5 TensList5 k1 k2 k3 (AnsVar (SField a))
t


tensorRank6' :: (TIndex k1, TIndex k2, TIndex k3, Real a) => AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar (SField a)) -> Int
tensorRank6' :: AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar (SField a)) -> Int
tensorRank6' AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar (SField a))
t = Matrix Double -> Int
forall t. Field t => Matrix t -> Int
rank (Matrix Double -> Int) -> Matrix Double -> Int
forall a b. (a -> b) -> a -> b
$ TensList6 k1 k2 k3 (AnsVar (SField a)) -> Matrix Double
forall k1 k2 k3 a.
(TIndex k1, TIndex k2, TIndex k3, Real a) =>
TensList6 k1 k2 k3 (AnsVar (SField a)) -> Matrix Double
toMatrixT6 (AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar (SField a))
-> TensList6 k1 k2 k3 (AnsVar (SField a))
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) k1 k2 k3 v.
AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 v -> TensList6 k1 k2 k3 v
singletonTList6 AbsTensor6 n1 n2 n3 n4 n5 n6 k1 k2 k3 (AnsVar (SField a))
t)

tensorRank6 :: (TIndex k1, TIndex k2, TIndex k3, Real a) => TensList6 k1 k2 k3 (AnsVar (SField a)) -> Int
tensorRank6 :: TensList6 k1 k2 k3 (AnsVar (SField a)) -> Int
tensorRank6 TensList6 k1 k2 k3 (AnsVar (SField a))
t = Matrix Double -> Int
forall t. Field t => Matrix t -> Int
rank (Matrix Double -> Int) -> Matrix Double -> Int
forall a b. (a -> b) -> a -> b
$ TensList6 k1 k2 k3 (AnsVar (SField a)) -> Matrix Double
forall k1 k2 k3 a.
(TIndex k1, TIndex k2, TIndex k3, Real a) =>
TensList6 k1 k2 k3 (AnsVar (SField a)) -> Matrix Double
toMatrixT6 TensList6 k1 k2 k3 (AnsVar (SField a))
t


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
tensorRank7' :: AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar (SField a))
-> Int
tensorRank7' AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar (SField a))
t = Matrix Double -> Int
forall t. Field t => Matrix t -> Int
rank (Matrix Double -> Int) -> Matrix Double -> Int
forall a b. (a -> b) -> a -> b
$ TensList7 k1 k2 k3 k4 (AnsVar (SField a)) -> Matrix Double
forall k1 k2 k3 k4 a.
(TIndex k1, TIndex k2, TIndex k3, TIndex k4, Real a) =>
TensList7 k1 k2 k3 k4 (AnsVar (SField a)) -> Matrix Double
toMatrixT7 (AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar (SField a))
-> TensList7 k1 k2 k3 k4 (AnsVar (SField a))
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) k1 k2 k3 k4 v.
AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 v
-> TensList7 k1 k2 k3 k4 v
singletonTList7 AbsTensor7 n1 n2 n3 n4 n5 n6 n7 k1 k2 k3 k4 (AnsVar (SField a))
t)

tensorRank7 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, Real a) => TensList7 k1 k2 k3 k4 (AnsVar (SField a)) -> Int
tensorRank7 :: TensList7 k1 k2 k3 k4 (AnsVar (SField a)) -> Int
tensorRank7 TensList7 k1 k2 k3 k4 (AnsVar (SField a))
t = Matrix Double -> Int
forall t. Field t => Matrix t -> Int
rank (Matrix Double -> Int) -> Matrix Double -> Int
forall a b. (a -> b) -> a -> b
$ TensList7 k1 k2 k3 k4 (AnsVar (SField a)) -> Matrix Double
forall k1 k2 k3 k4 a.
(TIndex k1, TIndex k2, TIndex k3, TIndex k4, Real a) =>
TensList7 k1 k2 k3 k4 (AnsVar (SField a)) -> Matrix Double
toMatrixT7 TensList7 k1 k2 k3 k4 (AnsVar (SField a))
t


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
tensorRank8' :: AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar (SField a))
-> Int
tensorRank8' AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar (SField a))
t = Matrix Double -> Int
forall t. Field t => Matrix t -> Int
rank (Matrix Double -> Int) -> Matrix Double -> Int
forall a b. (a -> b) -> a -> b
$ TensList8 k1 k2 k3 k4 (AnsVar (SField a)) -> Matrix Double
forall k1 k2 k3 k4 a.
(TIndex k1, TIndex k2, TIndex k3, TIndex k4, Real a) =>
TensList8 k1 k2 k3 k4 (AnsVar (SField a)) -> Matrix Double
toMatrixT8 (AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar (SField a))
-> TensList8 k1 k2 k3 k4 (AnsVar (SField a))
forall (n1 :: Nat) (n2 :: Nat) (n3 :: Nat) (n4 :: Nat) (n5 :: Nat)
       (n6 :: Nat) (n7 :: Nat) (n8 :: Nat) k1 k2 k3 k4 v.
AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 v
-> TensList8 k1 k2 k3 k4 v
singletonTList8 AbsTensor8 n1 n2 n3 n4 n5 n6 n7 n8 k1 k2 k3 k4 (AnsVar (SField a))
t)

tensorRank8 :: (TIndex k1, TIndex k2, TIndex k3, TIndex k4, Real a) => TensList8 k1 k2 k3 k4 (AnsVar (SField a)) -> Int
tensorRank8 :: TensList8 k1 k2 k3 k4 (AnsVar (SField a)) -> Int
tensorRank8 TensList8 k1 k2 k3 k4 (AnsVar (SField a))
t = Matrix Double -> Int
forall t. Field t => Matrix t -> Int
rank (Matrix Double -> Int) -> Matrix Double -> Int
forall a b. (a -> b) -> a -> b
$ TensList8 k1 k2 k3 k4 (AnsVar (SField a)) -> Matrix Double
forall k1 k2 k3 k4 a.
(TIndex k1, TIndex k2, TIndex k3, TIndex k4, Real a) =>
TensList8 k1 k2 k3 k4 (AnsVar (SField a)) -> Matrix Double
toMatrixT8 TensList8 k1 k2 k3 k4 (AnsVar (SField a))
t