6        !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                 Safe<=DR 9union binary lift : apply function on _union_ of two Sets Gintersection binary lift : apply function on _intersection_ of two Sets inner productmultiplication by a scalarRing zero elementRing +negate the values in a functorsubtract two Additive objectslinear interpolation #`hilbertDistSq x y = || x - y ||^2`!Squared 2-norm"L1 norm#Euclidean norm$Lp norm (p > 0)% Infinity-norm&"Normalize w.r.t. p-norm (p finite)'Lp inner product (p > 0)( Reciprocal)Scale* unary dimension-checking bracket+!binary dimension-checking bracket,  !"#$%&'()*+,  !"#$%&'()*+, !"#$%&'()*+     !"#$%&'()*+Safe ,Insert an element- Lookup a key.BPpopulate an IM2 from a list of (row index, column index, value) /7Indexed left fold over an IM2, with general accumulator0Indexed left fold over an IM21/Left fold over an IM2, with general accumulator2wInner indices become outer ones and vice versa. No loss of information because both inner and outer IntMaps are nubbed.3+Map over outer IM and filter all inner IM's47Specialized filtering : keep only sub-diagonal elements6<List of (row, col) indices of (nonzero) subdiagonal elements8 Map over IM29Indexed map over IM2: Mapping keys,-./0123456789:;<=>?@,-./0123456789:;@?>=<,-./0123456789:;,-./0123456789:;<=>?@SafeA eps = 1e-8 B Rounding ruleC Rounding ruleIKRound to respectively 0 or 1 within some predefined numerical precision eps ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHISafeLIComponentwise tuple operations TODO : use semilattice properties insteadMIComponentwise tuple operations TODO : use semilattice properties insteadNinteger-indexed ziplistO ", 2d arraysP foldr over the results of a fmapQstrict left foldRindexed right fold JKLMNOPQRSTUV JKLMNOPQRSTUV LMNOPQRKJSTUV JKLMNOPQRSTUVSafeWXYZWXYZZYXWWXYZSafe9;<=DR_SpVector sparsity`Number of nonzerosb*empty sparse vector (length n, no entries)c"singleton sparse vector (length 1)dQcreate a sparse vector from an association list while discarding all zero entriese3", from logically dense array (consecutive indices)g>Create new sparse vector, assumin 0-based, contiguous indexingh_one-hot encoding : `oneHotSV n k` produces a SpVector of length n having 1 at the k-th positionjDENSE vector of `1`skDENSE vector of `0`slinsert element x at index i in a preexisting SpVectoroTo dense list (default = 0)pLookup an index in a SpVectorq7Lookup an index, return a default value if lookup failsr8Lookup an index in a SpVector, returns 0 if lookup failss Tail elementst Head elementuConcatenate two sparse vectorsvFilterwIndexed filterx*Generate an arbitrary (not random) vector u such that `v dot u = 0`)[\]^_`abcdefghijklmnopqrstuvwxyz{|}~[\]^_`abcdefghijklmnopqrstuvwx)[\]^_`a~}|{zbcdefghijklmnoypqrstuvwx&[\]^_`abcdefghijklmnopqrstuvwxyz{|}~Safe9;<=DR1,`zeroSM m n` : Empty SpMatrix of size (m, n)"`eye n` : identity matrix of rank nPermutation matrix from a (possibly incomplete) list of row swaps starting from row 0 e.g. `permutationSM 5 [1,3]` first swaps rows (0, 1) and then rows (1, 3) :  0,1,0,0,0 0,0,0,1,0 0,0,1,0,0 1,0,0,0,0 0,0,0,0,1xPermutation matrix from a (possibly incomplete) list of row pair swaps e.g. `permutPairs 5 [(2,4)]` swaps rows (2, 4) :  1,0,0,0,0 0,1,0,0,0 0,0,0,0,1 0,0,0,1,0 0,0,1,0,09`mkSubDiagonal n o xx` creates a square SpMatrix of size n with xx on the oth subdiagonalDInsert an element in a preexisting Spmatrix at the specified indices?Add to existing SpMatrix using data from list (row, col, value):Create new SpMatrix using data from list (row, col, value)ECreate new SpMatrix assuming contiguous, 0-based indexing of elementsHPopulate list with SpMatrix contents and populate missing entries with 0`Looks up an element in the matrix with a default (if the element is not found, zero is returned)3Zero-default lookup, infix form (no bound checking)`Looks up an element in the matrix with a default (if the element is not found, zero is returned)^Zero-default lookup, infix form ("safe" : throws exception if lookup is outside matrix bounds)`Looks up an element in the matrix with a default (if the element is not found, zero is returned)fExtract a submatrix given the specified index bounds, rebalancing keys with the two supplied functions^Extract a submatrix given the specified index bounds NB : subtracts (i1, j1) from the indices\Extract a submatrix given the specified index bounds NB : submatrix indices are _preserved_!Extract column within a row range1Extract column within a row range, rebalance keysExtract all column!Extract column within a row range1Extract column within a row range, rebalance keys.Are the supplied indices within matrix bounds?Is the matrix square?Is the matrix diagonal?,is the matrix orthogonal? i.e. Q^t ## Q == I/Data in internal representation (do not export)#(Number of rows, Number of columns)&Number of rows times number of columnsNumber of rowsNumber of columnsVertical stackingVertical stackingHorizontal stackingHorizontal stackingLeft fold over SpMatrixIndexed left fold over SpMatrixCount sub-diagonal nonzeros`Filter the index subset that lies below the diagonal (used in the QR decomposition, for example)Sparsify an SpMatrix3Round almost-0 and almost-1 to 0 and 1 respectively0swap two rows of a SpMatrix (bounds not checked).swap two rows of a SpMatrix (bounds checked) $transposeSM, (#^) : Matrix transpose$transposeSM, (#^) : Matrix transposeRemoves all elements x for which `| x | <= eps`)Removes all elements x for which `| x | <= eps`)A^T BA B^T-Contract two matrices A and B up to an index nD, i.e. summing over repeated indices: Aij Bjk , for j in [0 .. n] QJQKSafeAInsert row , using the provided row index transformation functionInsert row CInsert column, using the provided row index transformation function Insert columnpromote a SV to SM.Demote (n x 1) or (1 x n) SpMatrix to SpVectorExtract ith rowExtract jth columnGeneric extraction functionExtract ith row (dense)Extract jth columnExtract the diagonalextract row interval>extract row interval, rebalance keys by subtracting lowest oneextract column intervalAextract column interval, rebalance keys by subtracting lowest oneMatrix-on-vectorMatrix-on-vector>Vector-on-matrix (FIXME : transposes matrix: more costly than  , I think)>Vector-on-matrix (FIXME : transposes matrix: more costly than  , I think)! !"#$%&'  !"#$%&'()*+,-./0123456789:;ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwx  !"#$%&' None 9:;<=DR#Sparsify an SpVector+uses the R matrix from the QR factorization a vector xS uniquely defines an orthogonal plane; the Householder operator reflects any point v3 with respect to this plane: v' = (I - 2 x >< x) v(Givens coefficients (using stable algorithm shown in Anderson, Edward (4 December 2000). "Discontinuous Plane Rotations and the Symmetric Eigenvalue Problem". LAPACK Working Note)zGivens method, row version: choose other row index i' s.t. i' is : * below the diagonal * corresponding element is nonzeroQR.C1 ) To zero out entry A(i, j) we must find row k such that A(k, j) is non-zero but A has zeros in row k for all columns less than j.)Is the k'th the first nonzero column in the row?*,Returns a set of rows {k} that satisfy QR.C1EApplies Givens rotation iteratively to zero out sub-diagonal elements+,Givens matrices in order [G1, G2, .. , G_N ]`eigsQR n mm` performs n* iterations of the QR algorithm on matrix mm3, and returns a SpVector containing all eigenvalues`eigsRayleigh n mm` performs n0 iterations of the Rayleigh algorithm on matrix mm and returns the eigenpair closest to the initialization. It displays cubic-order convergence, but it also requires an educated guess on the initial eigenpair LU factors,First iteration of LU-LU update step.+used for Incomplete LU : remove entries in m" corresponding to zero entries in m2/one step of TFQMR0one step of BCG one step of CGS Hiterate solver until convergence or until max # of iterations is reached one step of BiCGSTAB Hiterate solver until convergence or until max # of iterations is reached1GLeast-squares approximation of a rectangular system of equaitons. Uses  \ for the linear solve KLinear solve with _deterministic_ starting vector (every component at 0.1)  \0 : linSolve using the BiCGSTAB method as default2(transform state until a condition is met30Keep a moving window buffer (length 2) of state xw to assess convergence, stop when either a condition on that list is satisfied or when max # of iterations is reached 0Keep a moving window buffer (length 2) of state x to assess convergence, stop when either a condition on that list is satisfied or when max # of iterations is reached (i.e. same thing as 3& but this one runs in the State monad)4Oiterate until convergence is verified or we run out of a fixed iteration budget5convergence check (FIXME)6run niter! iterations and append the state x to a list xs, stop when either the xs satisfies a predicate q or when the counter reaches 0", NO convergence check Dense SpMatrixDense SpVector Sparse SpMatrixSparse SpVectord789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVW()*+X,-YZ[\]^_`a.b/0    1 23cd456$     )     @789:;<=>?@ABCDEFG HIJKLMNOPQRSTUVW()*+X,-YZ[\]^_`a.b/0    1 23cd456e     !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                     ! " # $ % & ' ()*+,-./0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D  E F  G H I  J K L M  N O P Q R S T U V W  X Y Z [ \ ] ^ _ ` a b c d e f g hi3sparse-linear-algebra-0.2.0.8-AONXvZKRZ04WoLdFjoiv5Numeric.LinearAlgebra.Class#Numeric.LinearAlgebra.Sparse.IntMap Numeric.EpsData.Sparse.UtilsData.Sparse.TypesData.Sparse.SpVectorData.Sparse.SpMatrixData.Sparse.CommonNumeric.LinearAlgebra.Sparse IxContainerIx ixcLookupixcLookupDefault ixcFilter ixcIfilter ixcInsert ixcFromList ixcToListSetliftU2liftI2SparsespyHasDataHDDatadat FiniteDimFDSizedimNormednormHilbertdot VectorSpace.*Additivezero^+^negated^-^lerp hilbertDistSqnormSqnorm1norm2normP normInfty normalizedotLp reciprocalscalewithDimwithDim2 insertIM2 lookupIM2 fromListIM2 ifoldlIM2' ifoldlIM2foldlIM2 transposeIM2 ifilterIM2 filterSubdiagcountSubdiagonalNZsubdiagIndicesrpairsmapIM2imapIM2 mapKeysIM2 mapColumnIM2$fNormedIntMap$fHilbertIntMap$fVectorSpaceIntMap$fAdditiveIntMap $fSetIntMapeps almostZero almostOneisNz withDefault roundZeroroundOne with2Defaults roundZeroOneUBLBmaxTupminTup denseIxArray denseIxArray2foldrMap foldlStrictifoldrinBounds inBounds2 inBounds0 inBounds02IxColIxRowColsRowsSpVectorSVsvDimsvDataspySVnzSV sizeStrSVzeroSV singletonSV mkSpVector mkSpVectorD mkSpVector1fromListDenseSV oneHotSVUoneHotSVonesSVzerosSVinsertSpVector fromListSVtoListSV toDenseListSVlookupSVlookupDefaultSV lookupDenseSVtailSVheadSVconcatSVfilterSV ifilterSV orthogonalSV$fShowSpVector$fNormedSpVector$fHilbertSpVector$fSparseSpVectora$fHasDataSpVectora$fFiniteDimSpVector$fVectorSpaceSpVector$fAdditiveSpVector$fFoldableSpVector $fSetSpVector$fFunctorSpVector $fEqSpVectorSMInfosmNzsmSpySpMatrixSMsmDimsmDatasizeStrzeroSM mkDiagonaleye permutationSM permutPairsSM mkSubDiagonalinsertSpMatrix fromListSM' fromListSMfromListDenseSM toDenseListSMlookupSM lookupWD_SM lookupWD_IM@@!@@extractSubmatrixSMextractSubmatrixRebalanceKeysextractSubmatrix extractRowSMextractSubRowSMextractSubRowSM_RK extractColSMextractSubColSMextractSubColSM_RK isValidIxSM isSquareSM isDiagonalSMisOrthogonalSMimmSMdimSMnelSMnrowsncolsinfoSMnzSMspySMnzRowbwMinSMbwMaxSM bwBoundsSM vertStackSM-=- horizStackSM-||-foldlSMifoldlSMcountSubdiagonalNZSMsubdiagIndicesSM sparsifyIM2 sparsifySMroundZeroOneSMswapRows swapRowsSafe transposeSM#^matScale normFrobeniusmatMat##matMatSparsified#~##^###^ contractSub$fSparseSpMatrixa$fHasDataSpMatrixa$fFiniteDimSpMatrix$fAdditiveSpMatrix $fSetSpMatrix$fFunctorSpMatrix$fShowSpMatrix $fEqSpMatrix $fEqSMInfo $fShowSMInfoprd insertRowWith insertRow insertColWith insertCol outerProdSV><svToSMtoSV extractRow extractColextractVectorDenseWithextractRowDenseextractColDenseextractDiagDense extractSubRowextractSubRow_RK extractSubColextractSubCol_RKmatVec#>vecMat<#$fPrintDenseSpMatrix$fPrintDenseSpVectorLinSolveMethodBICGSTAB _xBicgstabCGS_xBCG_xBcgTFQMR_xTfqCGNE_xCgne sparsifySVconditionNumberSMhhMathhReflgivensqreigsQR eigRayleighlucgnetfqmrbcgcgsStepcgs bicgstabStepbicgstablinSolve<\>modifyInspectNdiffSqL runAppendN'randMatrandVec randSpMat randSpVec$fShowBICGSTAB $fShowCGS $fShowBCG$fEqCGNE $fEqTFQMR$fEqBCG$fEqCGS $fEqBICGSTAB$fEqLinSolveMethod$fShowLinSolveMethod PrintDense showNonZero toDenseRowtoDenseRowClipnewline printDenseSMtoDenseListClip printDenseSV givensCoeffirstNonZeroColumn candidateRowsgmatsluInitluUpdripHoles tfqmrStepbcgSteppinv modifyUntil loopUntilAccuntilConvergednormDiffConverged runAppendNCGNE_TFQMR_BCG_CGS_ BICGSTAB_ _rBicgstab _pBicgstab_r_p_u_rBcg_rHatBcg_pBcg_pHatBcg_wTfq_uTfq_vTfq_dTfq_mTfq_tauTfq _thetaTfq_etaTfq_rhoTfq _alphaTfq_rCgne_pCgnehypotsignhhVuUpd'uUpd uUpdSparse solveForUij solveForLijlUpd'lUpd lUpdSparsepermutAAcgneStepmeanlnorm2l