94   None&'FST   To define a sparseT dimension we need a cumulative array, an index array and a dimensionality parameter Cumulative array (# nonzero entries per degree of freedom). Not all storage formats (e.g. COO for rank-2 tensors) need this information. (Index array (indices of nonzero entries)'Size of the tensor along this dimension To define a dense4 dimension we only need the dimensionality parameter1A tensor dimension can be either dense or sparse.Example: the CSR format is dense in the first index (rows) and sparse in the second index (columns)    None&'FST wA statically-typed tensor shape parameter that supports both sparse and dense dimensions. Dimensions are indexed with 7 indices, which should be enough for most applications.$Note: in this formulation, only the rank (i.e. the number of dimensions) is known at compile time. The actual dimensionality is only known at runtime. To address this, see Data.Shape.Static#Constructor for a dense dimension #Constructor for a sparse dimension #A class for data that have a shape.+Rank of a shape (i.e. number of dimensions)3Dimension of a shape (i.e. list of dimension sizes)Shape of a dense vectorShape of a sparse vector)Shape of a dense rank-2 tensor (a matrix)MShape of a rank-2 CSR tensor (dense in the first index, sparse in the second) 5Shape of a rank-2 COO tensor (sparse in both indices)!"#$%&'()*+,- &-,+*None./0123./0None&',-;=>?FQSTV4/A shape type with statically typed dimensions 5!Constructor for a dense dimension6"Constructor for a sparse dimension 784965:;<=>?@784956=5>5None &'3;=FSTU AThe AU type with statically known shape. Tensor data entries are stored as one single arrayB3A tensor type with dimensions only known at runtimeC8Construct a tensor given a shape and a vector of entriesDAccess the shape of a AEAccess the raw data of a AF!Number of nonzero tensor elementsG Tensor rankHTensor dimensions  &AIDEFGHAIBJKLSafe&''MInternal representationNinner product of two vectorsmatrix-vector actionmatrix-matrix product User-facing syntaxO-Evaluate user-facing syntax into internal onePEvaluate the internal representation into a concrete result. NB: the internal and returned type, [b], is constrained by the evaluation functions Q/R:. In general this would be an opaque tensor data structureSE2 combinatorsTChained E1 -> E2 evaluationUVWXYMZ[\N]^OPS_`TaUYWXVM\Z[N^]Safe&'QV/gParametric higher-order abstract syntax (PHOAS), after B. Oliveira, A. Loeh, `Abstract Syntax Graphs for Domain Specific Languages` *Inject a constant into the abstract syntaxBind a variable into a closure!Bind two variables into a closurebHelper functions c9Benchmark: `tree 50` should compute the answer instantly.AThis proves that the PHOAS formulation preserves variable sharing Semantic function for evaluation debfgcedNone&'U3Tensor contraction Inject two A constant into e\s, while ensuring that all the contraction indices are compatible with those of the tensors. Throws a L if any index is nonnegative or too large for the shape of the given tensor. Exceptionsh      !"#$%&'()*+,-./0.12345567# !88.9! /0:;<=>?@A#<=BCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`a#taco-0.3.0.0-LqC1W8Lu4Jb46gFXS3S9ofData.Tensor.CompilerData.Dim Data.ShapeData.Shape.DynamicData.Shape.Static Data.TensorData.Tensor.Compiler.MultiStageData.Tensor.Compiler.PHOASPhoasvarlet_let2_eval CException IncompatShape IncompatIx$fExceptionCException$fShowCException$fEqCExceptionSdsCmlsIdxsDimDddimdDimDimShbaseGHC.IntInt32DSShaperankmkD1mkS1mkD2mkCSRmkCOOCOOCSRD2S1D1Z:.:#shDimshRankshapeShapeTShDunShD mkDenseShDSizedDimzt0shToListTensorTenzormkTtshapetdatannztzShapetzDataE2E1evalE1evalE2GHC.ListzipWith Data.Foldablefoldrk2evalEBinOpDivSubMulAddZipWithFoldK2DotK1addE2mulE2 evalBinOplift1treeELetVarlift2plus