وx      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvw,(C) 2016 Marco Zocca, 2012-2015 Edward KmettGPL-3 (see LICENSE)zocca.marco gmail provisionalportableSafe9; 2Provides a test to see if a quantity is near zero.nearZero (1e-11 :: Double)FalsenearZero (1e-17 :: Double)TruenearZero (1e-5 :: Float)FalsenearZero (1e-7 :: Float)True%Determine if a quantity is near zero.Is this quantity close to 1 ?)Is this quantity distinguishable from 0 ?Round to respectively 0 or 1 x a y 1e-12 x a y 1e-6 x a y 1e-12 x a y 1e-6 z a y 1e-12 z a y 1e-6 z a y 1e-12 z a y 1e-6{| {| None }JIntersection and union of sparse lists having indices in _ascending_ order~AIntersection of sparse lists having indices in _descending_ order:Union of sparse lists having indices in _descending_ order7Lift a binary function onto the second entry of a tuple5Wrap a function with a null check, returning in MaybeIComponentwise tuple operations TODO : use semilattice properties insteadIComponentwise tuple operations TODO : use semilattice properties insteadinteger-indexed ziplist ", 2d arrays foldr over the results of a fmapstrict left foldindexed right fold}~}~}~ Safe(c) Marco Zocca 2017GPL-3 (see the file LICENSE)zocca marco gmail experimentalportableNone *9:;<=DR+!;Union binary lift : apply function on _union_ of two "sets""IIntersection binary lift : apply function on _intersection_ of two "sets"$'Sparsity (fraction of nonzero elements)'Number of nonzeros+:Dimension (i.e. Int for SpVector, (Int, Int) for SpMatrix)->Solve a linear system; uses GMRES internally as default method1Matrix-vector action2Dual matrix-vector action3}A matrix ring is any collection of matrices over some ring R that form a ring under matrix addition and matrix multiplication5Matrix-matrix product6%Matrix times matrix transpose (A B^T)7%Matrix transpose times matrix (A^T B)8:Matrix transpose (Hermitian conjugate in the Complex case)9Frobenius norm=L1 norm>Euclidean (L2) norm squared?Lp norm (p > 0)@Normalize w.r.t. Lp normANormalize w.r.t. L2 normB(Normalize w.r.t. norm2' instead of norm2CEuclidean (L2) normDMEuclidean (L2) norm; returns a Complex (norm :+ 0) for Complex-valued vectorsELp norm (p > 0)FAdds inner (dot) products.GInner/dot productJScale a vectorL&The zero element: identity for '(^+^)'M Add vectorsNAdditive inverseOGroup subtractionRCComplex conjugate, or identity function if its input is real-valuedS MagnitudeT Inner productUEScale a vector by the reciprocal of a number (e.g. for normalization)VVector multiplied by scalarW,Convex combination of two vectors (NB: 0 <= a <= 1). XX`hilbertDistSq x y = || x - y ||^2` computes the squared L2 distance between two vectorsYInfinity-norm (Real)ZInfinity-norm (Complex)[Lp inner product (p > 0)\ Reciprocal]Scale^)Lift a real number onto the complex planeS !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`aP "!#$%&'()*+,-./0213485769:<;ECD@AB=>?FGHIJKMOLNPQRSTUVWXYZ[\]^SPQRSa`_KLMNOHIJFGTUVWX:;<=>?@ABCDEYZ[\]3456789/012.,-)*+%&'(#$ !"^ !"#$%&'()*+,-./0123456789: ;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`aJ7M6O6U7V7 (C) 2016 Marco ZoccaGPL-3 (see LICENSE)zocca.marco gmail provisionalportableSafe!": )Pretty printing options: total length in ' digits (including the decimal point),  of decimal digitsb&Pretty-print with a descriptive headercPretty-print with no header Some defaults Some defaults%Pretty print an array of real numbers(Pretty print an array of complex numbersJprintf an array of items with padding space to render a fixed column widthprintf format string"printf format string for a ComplexHelpersbcLength of list to be provided cbbc None 9;<=ADRT:Stream fusion based version of the above, from [1] [1] : Thttps://www.schoolofhaskell.com/user/edwardk/revisiting-matrix-multiplication/part-3&Given a number of rows(resp. columns) n: and a _sorted_ Vector of Integers in increasing order (containing the row(col) indices of nonzero entries), return the cumulative vector of nonzero entries of length `n + 1` (the "row(col) pointer" of the CSR(CSC) format). NB: Fused count-and-accumulate E.g.: > csPtrV (==) 4 (V.fromList [1,1,2,3]) [0,0,2,3,4]<O(N) : Intersection between sorted vectors, in-place updates5O(N) : Union between sorted vectors, in-place updates"" NoneAT None:DRltraverse the sparse mutable vector and operate on the union set between the indices of the immutable vector v and those of the mutable one vm?, _overwriting_ the values in vm. Invariant: the index set of v is a strict subset of that of vm (i.e. we assume that vmZ is preallocated properly, or, we assume there won't be any out-of-bound writes attempted)None 9;<=DR.O(N) : Lookup an index in a SVector (based on find from Data.Foldable)O(N) : Applies a function to the index _intersection_ of two CsrVector s. Useful e.g. to compute the inner product of two sparse vectors.O(N) : Applies a function to the index _union_ of two CsrVector s. Useful e.g. to compute the vector sum of two sparse vectors.`Modify the mutable vector operand by applying a binary function over the index union of the two.e.g.7g = (+) z = 0 u = [(1, a), (2, b)] v = [(0, d), (2, e)]3unionWithSMV g z u v = [(0, d), (1, a), (2, b + e)] invariants :uu, vv nonzero valuesixu, ixv nonzero indices"ixu, ixv sorted in ascending ordern1 == n2length ixu == length uulength ixv == length vvNone29;DR Sparse listFNB : unionWith and intersectWith work only if the indices are _sorted_.NB2 : we use the _descending_ order comparison"Inner product between sparse listsVector sum of sparse lists`vector-space` instances  None 249;DIRA synonym for IntMap                None9;<=DRnInsert an element insertIM2 :: IM.Key -> IM.Key -> a -> IM.IntMap (IM.IntMap a) -> IM.IntMap (IM.IntMap a) TLookup a key lookupIM2 :: IM.Key -> IM.Key -> IM.IntMap (IM.IntMap a) -> Maybe a!Lookup with default 0"Populate an IM2 from a list of (row index, column index, value) fromListIM2 :: Foldable t => t (IM.Key, IM.Key, a) -> IM.IntMap (IM.IntMap a) -> IM.IntMap (IM.IntMap a)#Indexed left fold over an IM2, with general accumulator ifoldlIM2' :: (IM.Key -> IM.Key -> a -> b -> b) -> b -> IM.IntMap (IM.IntMap a) -> b$Indexed left fold over an IM2 ifoldlIM2 :: (IM.Key -> IM.Key -> t -> IM.IntMap a -> IM.IntMap a) -> IM.IntMap (IM.IntMap t) -> IM.IntMap a%oLeft fold over an IM2, with general accumulator foldlIM2 :: (a -> b -> b) -> b -> IM.IntMap (IM.IntMap a) -> b&Inner indices become outer ones and vice versa. No loss of information because both inner and outer IntMaps are nubbed. transposeIM2 :: IM.IntMap (IM.IntMap a) -> IM.IntMap (IM.IntMap a)'Map over outer IM and filter all inner IM's ifilterIM2 :: (IM.Key -> IM.Key -> a -> Bool) -> IM.IntMap (IM.IntMap a) -> IM.IntMap (IM.IntMap a)(|Specialized filtering : keep only sub-diagonal elements filterSubdiag :: IM.IntMap (IM.IntMap a) -> IM.IntMap (IM.IntMap a))}List of (row, col) indices of (nonzero) subdiagonal elements subdiagIndices :: IM.IntMap (IM.IntMap a) -> [(IM.Key, IM.Key)]* Map over IM2+|Indexed map over IM2 imapIM2 :: (IM.Key -> IM.Key -> a -> b) -> IM.IntMap (IM.IntMap a) -> IM.IntMap (IM.IntMap b),}Mapping keys mapKeysIM2 :: (IM.Key -> IM.Key) -> (IM.Key -> IM.Key) -> IM.IntMap (IM.IntMap a) -> IM.IntMap (IM.IntMap a) !"#$%&'(-).*+,/ !"#$%&'(-).*+,/ !"#$%&'(-).*+,/(C) 2016 Marco ZoccaGPL-3 (see LICENSE)zocca.marco gmail provisionalportableNone 249:;<=DR?dInternal implementationp,`zeroSM m n` : Empty SpMatrix of size (m, n)q5`mkDiagonal n ll` : create a diagonal matrix of size n from a list ll of elementsr"`eye n` : identity matrix of rank nsPermutation 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) :.prd (permutationSM 5 [1,3] :: SpMatrix Double)  ( 5 rows, 5 columns ) , 5 NZ ( density 20.000 % ) _ , 1.00 , _ , _ , _ _ , _ , _ , 1.00 , _ _ , _ , 1.00 , _ , _ 1.00 , _ , _ , _ , _ _ , _ , _ , _ , 1.00 tyPermutation matrix from a (possibly incomplete) list of row pair swaps e.g. `permutPairs 5 [(2,4)]` swaps rows 2 and 4 :0prd (permutPairsSM 5 [(2,4)] :: SpMatrix Double)  ( 5 rows, 5 columns ) , 5 NZ ( density 20.000 % ) 1.00 , _ , _ , _ , _ _ , 1.00 , _ , _ , _ _ , _ , _ , _ , 1.00 _ , _ , _ , 1.00 , _ _ , _ , 1.00 , _ , _ u9`mkSubDiagonal n o xx` creates a square SpMatrix of size n with xx on the oth subdiagonalvDInsert an element in a preexisting Spmatrix at the specified indicesw?Add to existing SpMatrix using data from list (row, col, value)xVCreate new SpMatrix using data from a Foldable (e.g. a list) in (row, col, value) form{ECreate new SpMatrix assuming contiguous, 0-based indexing of elements|$Populate list with SpMatrix contents}HPopulate 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)Indexed filtering functionbDiagonal, subdiagonal, superdiagonal partitions of a SpMatrix (useful for writing preconditioners)bDiagonal, subdiagonal, superdiagonal partitions of a SpMatrix (useful for writing preconditioners)bDiagonal, subdiagonal, superdiagonal partitions of a SpMatrix (useful for writing preconditioners)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 whole 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 lower/upper triangular?%Is the matrix lower/upper triangular?,Is the matrix orthogonal? i.e. Q^t ## Q == I_Data in internal representation (do not export) immSM :: SpMatrix t -> IM.IntMap (IM.IntMap t)#(Number of rows, Number of columns)&Number of rows times number of columnsNumber of rowsNumber of columns"Vertical stacking of matrix blocks"Vertical stacking of matrix blocks$Horizontal stacking of matrix blocks$Horizontal stacking of matrix blocksoAssemble a block-diagonal square matrix from a list of square matrices, arranging these along the main diagonalIndexed filter over SpMatrixLeft 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 respectivelyModify (row, column) keys, leaving data intact. Be careful when using this! modifyKeysSM' :: (IxRow -> IxRow) -> (IxCol -> IxCol) -> SpMatrix a -> SpMatrix a0Swap two rows of a SpMatrix (bounds not checked).Swap two rows of a SpMatrix (bounds checked) transposeSM : Matrix transposeHermitian conjugate Matrix trace'Matrix product without dimension checks1After multiplying the two matrices, all elements x& for which `| x | <= eps` are removed.1After multiplying the two matrices, all elements x& for which `| x | <= eps` are removed.Sparsifying A B^TSparsifying A^T B Contract row i of A with column j of B up to an index nD, i.e. summing over repeated indices: Aij Bjk , for j in [0 .. n] kces are sparse containers too, i.e. any specific component may be missing (so it is assumed to be 0)k-es are maps between finite-dimensional spaceskbes form an additive group, in that they can have an invertible associtative operation (matrix sum)bdefghijklmnopqrstuvwxyz{|}~Ydefghijklmnopqrstuvwxyz{|}~bklmnopqrstuvwxyz{|}~ghijdefZdefghijklmnopqrstuvwxyz{|}~None9;<=DR0O(N log N) : Copy a Vector containing (row index, column index, entry) into a CSC structure. Sorts the Vector by row columns ( O(log N) ), unzips row indices and data ( O(N) ) and generates the column pointer vector ( 2 O(N) passes )1MO(N) : Rebuilds the (row, column, entry) Vector from the CSC representation. 2,O(1) : extract a column from the CSC matrix.3!O(N log N) : Transpose CSC matrix456789:;01<2=3>?@ABCD456789:;01<2=3>456789:;01<2=3>?@ABCDNone2E CSB Block\Invariants : 1) rowIx, colIx and val have same length 2) " have at most (bRows x bCols) NZFBWhich block (in row, col format) do matrix indices (i,j) fall in ?GBlock coordinatesBWhich block (in row, col format) do matrix indices (i,j) fall in ?HBlock index (row-major order)IEJKLMNOPQR Matrix size(Block parameter (i.e. block edge length)# of blocks per sideFGHSTIEJKLMNOPQRFGHSTIEJKLMNOPQRFGHSTNoneNumerical iteration errorsMatrix exceptionsOperand size mismatch errorsOut of bounds index errors Input errors(Errors associated with partial functions(c) Marco Zocca 2017 GPL-style (see the file LICENSE)zocca marco gmail experimentalportableNone2:Iprint function for type bMax.# of iterationsPrint iteration info to stdout Project state to a type bU5modifyUntil with optional iteration logging to stdout is a special case of H that assesses convergence based on the L2 distance to a known solution xKnown0This function makes some default choices on the  machinery: convergence is assessed using the squared L2 distance between consecutive states, and divergence is detected when this function is increasing between pairs of measurements.", monadic version is a high-order abstraction of a numerical iterative process. It accumulates a rolling window of 3 states and compares a summary qf of the latest 2 with that of the previous two in order to assess divergence (e.g. if `q latest2 > q prev2` then the function throws an exception and terminates). The process ends by either hitting an iteration budget or by relative convergence, whichever happens first. After the iterations stop, the function then assesses the final state with a predicate qfinalw (e.g. for comparing the final state with a known one; if this is not available, the user can just supply `const True`)", monadic versionVSome useful combinatorsoApply a function over a range of integer indices, zip the result with it and filter out the almost-zero entriesW", monadic versionX%A combinator I don't know how to callYHelpersRelative residualZ7Squared difference of a 2-element list. | NB: unsafe ![TRelative tolerance : relTol a b := ||a - b|| / (1 + min (||norm2 a||, ||norm2 b||))'\]^_`abcdeUf Known value Calling function name ConfigurationState summary array projectionConvergence criterionDivergence criterion Final state acceptance criterionState evolution Initial state Final stateVWghXYZ[ijklmn&\]^_`abcdeUfVWghXYZ[ijklm\]^_`abcdeUfVWghXYZ[ijklmn(C) 2016 Marco ZoccaGPL-3 (see LICENSE)zocca.marco gmail provisionalportableNone 29:;<=DIR(SpVector densityNumber of nonzeros *Empty sparse vector (length n, no entries) "Singleton sparse vector (length 1) Canonical basis vector in R^n HSparse vector from an association list while discarding all zero entries(Dense real SpVector (monomorphic Double)+Dense complex SpVector (monomorphic Double)>Create new sparse vector, assumin 0-based, contiguous indexing^Map a function over a range of indices and filter the result (indices and values) to fit in a n-long SpVector0", using just the integer bounds of the interval_one-hot encoding : `oneHotSV n k` produces a SpVector of length n having 1 at the k-th positionDENSE vector of `1`sDENSE vector of `0`s#DENSE vector with constant elements3Populate a SpVector with the contents of a Vector. jPopulate a Vector with the entries of a SpVector, discarding the indices (NB: loses sparsity information).VPopulate a Vector with the entries of a SpVector, replacing the missing entries with 0insert element x at index i: in a preexisting SpVector; discards out-of-bounds entriesSCreate new SpVector using data from a Foldable (e.g. a list) in (index, value) form  Create a dense! SpVector from a list of Double's! Create a dense) SpVector from a list of Complex Double's"&Populate a list with SpVector contents#To dense list (default = 0)$Indexed fold over SpVector%Lookup an index in a SpVector&7Lookup an index, return a default value if lookup fails'8Lookup an index in a SpVector, returns 0 if lookup fails( Tail elements) Head element*2Keep the first n components of the SpVector (like o for lists)+LDiscard the first n components of the SpVector and rebalance the keys (like p for lists)2Keep the first n components of the SpVector (like o for lists),Keep a range of entries -Concatenate two sparse vectors.Filter/Indexed filter0Sparsify an SpVector1*Generate an arbitrary (not random) vector u such that `v dot u = 0`2bs are sparse containers too, i.e. any specific component may be missing (so it is assumed to be 0)5@s form a vector space because they can be multiplied by a scalar s are finite-dimensional vectors;      !"#$%&'()*+,-./01234567893      !"#$%&'()*+,-./01;98765432      !"#$%&'()*+,-./018      !"#$%&'()*+,-./0123456789(C) 2016 Marco ZoccaGPL-3 (see LICENSE)zocca.marco gmail provisionalportableNone %&9:;DQRq2Modify the size of a SpVector. Do not use directlyr1Remap the keys of a SpVector. Do not use directly;AInsert row , using the provided row index transformation function<Insert row =CInsert column, using the provided row index transformation function> Insert column? Outer product@ Outer productAAFill the diagonal of a SpMatrix with the components of a SpVectorBpromote a SV to SMC.Demote (n x 1) or (1 x n) SpMatrix to SpVectorDRLookup a row in a SpMatrix; returns an SpVector with the row, if this is non-emptyEExtract ith rowFExtract jth columnGGeneric extraction functionHExtract ith row (dense)IExtract jth columnJExtract the diagonalK&extract row interval (all entries between columns j1 and j2, INCLUDED, are returned) extractSubRow :: SpMatrix a -> IxRow -> (IxCol, IxCol) -> SpVector a extractSubRow m i (j1, j2) = case lookupRowSM m i of Nothing -> zeroSV (ncols m) Just rv -> ifilterSV (j _ -> j >= j1 && j <= j2) rv", returning in Maybe extractSubRow :: SpMatrix a -> IxRow -> (Int, Int) -> Maybe (SpVector a) extractSubRow m i (j1, j2) = resizeSV (j2 - j1) . ifilterSV (j _ -> j >= j1 && j  =j2) <$ lookupRowSM m iExtract an interval of SpVector components, changing accordingly the resulting SpVector size. Keys are _not_ rebalanced, i.e. components are still labeled according with respect to the source matrix.L>extract row interval, rebalance keys by subtracting lowest oneMextract column intervalNAextract column interval, rebalance keys by subtracting lowest ones>Vector-on-matrix (FIXME : transposes matrix: more costly than matVec , I think)O/Pack a list of SpVectors as rows of an SpMatrixP/Pack a list of SpVectors as columns an SpMatrixQ7Unpack the rows of an SpMatrix into a list of SpVectorsR:Unpack the columns of an SpMatrix into a list of SpVectorsS6Pack a V.Vector of SpVectors as columns of an SpMatrixT3Pack a V.Vector of SpVectors as rows of an SpMatrix.qr;<=>?@ABCDEFGHIJKLMNtsOPQRSTuvwxyz{|}~UVWX(}~ "!#$%&'()*+,-./0213485769:<;ECD@AB=>?FGHIJKMOLNPQRSTUVWXYZ[\]^bcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./01;<=>?@ABCDEFGHIJKLMNOPQRST;<=>A?@CBDFEGHIJKMLNOTSPQR.qr;<=>?@ABCDEFGHIJKLMNtsOPQRSTuvwxyz{|}~UVWXNone 2349:;DR)triangular sparse matrix, row-major orderRIntmap-of-sparse lists * fast random access of rows * fast consing of row elementsGiven a lower triangular system L x = b, finds the nonzero entries of the solution vector x as the set of reachable nodes from the r.h.s. via the graph G(L^T). Node indices are _sorted_ afterwards, for a total complexity of O(N)"Build the initial solution vector x= for the triangular solve, given a vector of nonzero indices ixnz. and the right hand side of the linear system bbf: -- 1. Initialize an empty mutable vector of length `length ixnz` to 0 -- 2. Copy the entries from bb to x.)Note: this assumes that the index set of bb& is strictly contained within that of x: (which is true for the case of the triangular solve, see )%`appendIM i x im` appends an element x3 to the i'th SList in an IntMap-of-SLists structure$Nested lookup with default value = 07LU factorization : store L and U^T in TriMatrix format  row lookup in-row lookupL, U$updated U, i'th diagonal element Uii'diagonal element of U (must be nonzero) updated LNone:DR`eigRayleigh 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.kGolub-Kahan-Lanczos bidiagonalization (see "Restarted Lanczos Bidiagonalization for the SVD", SLEPc STR-8,  ,http://slepc.upv.es/documentation/manual.htm )None:DR None *.9:;<=DRY$Iterative methods for linear systemsZGeneralized Minimal RESidual [*Conjugate Gradient on the Normal Equations\BiConjugate Gradient]Conjugate Gradient Squared^BiConjugate Gradient Stabilized'A lumped constraint for numerical types_nMatrix condition number: computes the QR factorization and extracts the extremal eigenvalues from the R factor`!Householder reflection: a vector xw uniquely defines an orthogonal (hyper)plane, i.e. an orthogonal subspace; the Householder operator reflects any point v- through this subspace: v' = (I - 2 x >< x) va3Givens matrix : a planar rotation embedded in R^n. aa = fromListSMg <- givens aa 1 0Row version of the method: given a matrix element below the diagonal, indexed (i,j), choose a row index i' that is below the diagonal as well and distinct from i such that the corresponding element is nonzero.To zero out entry A(i, j) we must find row i' such that A(i', j) is non-zero but A has zeros in row i' for all column indices < j.9NB: The Givens' matrix differs from Identity in 4 entriesANB2: The form of a Complex rotation matrix in R^2 is as follows ( indicates complex conjugation): - ( c s ) G =( ) ( -s* c*) 1Givens coefficients and norm of associated vectorbGiven a matrix A, returns a pair of matrices (Q, R) such that Q R = A, where Q is orthogonal and R is upper triangular. Applies Givens rotation iteratively to zero out sub-diagonal elements.NB: at each iteration i we multiply the Givens matrix G_i by the previous partial result M0. Since this corresponds to a rotation, and the Q function already computes the value of the resulting non-zero component (output r@), `G_i ## M` can be simplified by just updating two entries of M3 (i.e. zeroing one out and changing the other into r).%However, we must also accumulate the G_i in order to build Q>, and the present formulation follows this definition closely.c`eigsQR n mm` performs at most n* iterations of the QR algorithm on matrix mm4, and returns a SpVector containing all eigenvalues.d:`eigsArnoldi n aa b` computes at most n iterations of the Arnoldi algorithm to find a Krylov subspace of (A, b), denoted Q, along with a Hessenberg matrix of coefficients H. After that, it computes the QR decomposition of H, denoted (O, R) and the eigenvalues {_i} of A are listed on the diagonal of the R factor.e*Given a positive semidefinite matrix A, returns a lower-triangular matrix L such that L L^T = A . This is an implementation of the Cholesky Banachiewicz algorithm, i.e. proceeding row by row from the upper-left corner. | NB: The algorithm throws an exception if some diagonal element of A is zero.fGiven a matrix A, returns a pair of matrices (L, U) where L is lower triangular and U is upper triangular such that L U = A . Implements the Doolittle algorithm, which sets the diagonal of the L matrix to ones and expects all diagonal entries of A to be nonzero. Apply pivoting (row or column permutation) to enforce a nonzero diagonal of the A matrix (the algorithm throws an appropriate exception otherwise).g4Given a matrix A, a vector b and a positive integer n-, this procedure finds the basis of an order n Krylov subspace (as the columns of matrix Q), along with an upper Hessenberg matrix H, such that A = Q^T H Q. At the i`th iteration, it finds (i + 1) coefficients (the i`th column of the Hessenberg matrix H) and the (i + 1)`th Krylov vector.hWPartition a matrix into strictly subdiagonal, diagonal and strictly superdiagonal partsAThe Jacobi preconditioner is just the reciprocal of the diagonal Used for Incomplete LU : remove entries in the output matrix corresponding to zero entries in the input matrix (this is called ILU(0) in the preconditioner literature)Symmetric Successive Over-Relaxation. `mSsor aa omega` : if `omega = 1` it returns the symmetric Gauss-Seidel preconditioner. When  = 1, the SOR reduces to Gauss-Seidel; when  > 1 and  < 1, it corresponds to over-relaxation and under-relaxation, respectively.iGDirect solver based on a triangular factorization of the system matrix.jForward substitution solverkBackward substitution solver&Given a linear system `A x = b` where AR is an (m x m) real-valued matrix, the GMRES method finds an approximate solution xhatI such that the Euclidean norm of the residual `A xhat - b` is minimized. xhat is spanned by the order-n Krylov subspace of (A, b). In this implementation: 1) the Arnoldi iteration is carried out until numerical breakdown (therefore yielding _at_most_ `m+1` Krylov basis vectors) 2) the resulting Hessenberg matrix H is factorized in QR form (H = Q R) 3) the Krylov-subspace solution yhato is found by backsubstitution (since R is upper-triangular) 4) the approximate solution in the original space xhat6 is computed using the Krylov basis, `xhat = Q_n yhat`A common optimization involves interleaving the QR factorization (and the subsequent triangular solve) with the Arnoldi process (and employing an updating QR factorization which only requires one Givens' rotation at every update). lALeast-squares approximation of a rectangular system of equations.m-Interface method to individual linear solversIYZ[\]^_`abQ, RcMax. # of iterationsPrint debug information Operand matrixEigenvalues {_i}d Q, O, {_i}eLfL, Ug System matrixr.h.s.Max. # of iterationsQ, Hh/Subdiagonal, diagonal, superdiagonal partitionsL, U (with holes)relaxation factorLeft, right factorsiLower triangularUpper triangularr.h.s.jklmnopqd$'+-2198675=BA@DCEGJUWXcbqrstux| !"./@OPQRSTYZ[\]^_`abcdefghijklmd-lijkcdbfega_`h" !x|OQPRTSrqust./JUG12576@+'$WECD@AB=X89bcmYZ[\]^1YZ[\]^_`abcdefghijklmnopq !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxy z {|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                                                           0      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgghijklmnopqrstuvwxyzy{|}~}4sparse-linear-algebra-0.2.9.8-2hNe3uWlxy8CrkInHNMim8 Numeric.EpsNumeric.LinearAlgebra.ClassNumeric.LinearAlgebra.SparseData.Sparse.SpMatrixControl.Exception.CommonData.Sparse.SpVectorData.Sparse.CommonData.Sparse.UtilsData.Sparse.TypesData.Sparse.PPrintData.Sparse.Internal.UtilsData.Sparse.Internal.Stream$Data.Sparse.Internal.SVector.MutableData.Sparse.Internal.SVectorData.Sparse.Internal.SListData.Sparse.Internal.IntMData.Sparse.Internal.IntMap2Data.Sparse.Internal.CSCData.Sparse.Internal.CSBControl.IterativeData.Sparse.Internal.TriMatrix/Numeric.LinearAlgebra.EigenSolvers.Experimental0Numeric.LinearAlgebra.LinearSolvers.ExperimentalEpsilonnearZeronearOneisNz roundZeroroundOne roundZeroOne$fEpsilonComplex$fEpsilonComplex0$fEpsilonComplex1$fEpsilonComplex2$fEpsilonCDouble$fEpsilonCFloat$fEpsilonDouble$fEpsilonFloat SparseMatrix smFromVector smTransposeencodeIxdecodeIx SparseVectorSpvIx svFromListsvFromListDensesvConcat SpContainerScIxScElemscInsertscLookupscToList@@SetliftU2liftI2SparsespyHasDataHDDatannzdat FiniteDimFDSizedim LinearSystem<\>VLinearVectorSpace MatrixType#><# MatrixRing MatrixNorm####^#^# transpose normFrobeniusNormed Magnitude RealScalarnorm1norm2SqnormP normalize normalize2 normalize2'norm2norm2'norm InnerSpace<.> VectorSpaceScalar.* AdditiveGroupzeroV^+^negateV^-^EltEltMagconjmagdot./*.cvx hilbertDistSq normInftyR normInftyCdotLp reciprocalscaletoC $fEltComplex $fEltFloat $fEltDoubleprdprd0MatProd_ABABtSMInfosmNzsmSpySpMatrixSMsmDimsmData sizeStrSMzeroSM mkDiagonaleye permutationSM permutPairsSM mkSubDiagonalinsertSpMatrix fromListSM' fromListSMmkSpMRmkSpMCfromListDenseSMtoListSM toDenseListSMlookupSM lookupWD_SM@@!filterSMextractSubDiagextractSuperDiag extractDiagextractSubmatrixSMextractSubmatrixRebalanceKeysextractSubmatrixtakeRowstakeCols extractColSMextractSubColSMextractSubColSM_RK isValidIxSM isSquareSM isDiagonalSM isLowerTriSM isUpperTriSMisOrthogonalSMimmSMdimSMnelSMnrowsncolsinfoSMnzSMspySMnzRowbwMinSMbwMaxSM bwBoundsSM vertStackSM-=- horizStackSM-||-fromBlocksDiag ifilterSMfoldlSMifoldlSMcountSubdiagonalNZSMsubdiagIndicesSM sparsifyIM2 sparsifySMroundZeroOneSM modifyKeysSM' modifyKeysSMswapRows swapRowsSafe transposeSM hermitianConjmatScaletracenormFrobeniusSMnormFrobeniusSMCmatMat_matMatUnsafeWithmatMatSparsified#~##~^##~#^ contractSub$fMatrixRingSpMatrix$fMatrixRingSpMatrix0$fSpContainerSpMatrix$fSparseSpMatrix$fHasDataSpMatrix$fFiniteDimSpMatrix$fAdditiveGroupSpMatrix $fSetSpMatrix$fShowSpMatrix $fEqSpMatrix$fFunctorSpMatrix$fFoldableSpMatrix $fEqSMInfo $fShowSMInfo $fEqMatProd_$fShowMatProd_IterationException NotConvergedE DivergingEMatrixExceptionHugeConditionNumber NeedsPivotingOperandSizeMismatchDotSizeMismatchNonTriangularExceptionMatVecSizeMismatchExceptionOutOfBoundsIndexError OOBIxError OOBIxsErrorOOBNoCompatRows InputError NonNegErrorPartialFunctionError EmptyList checkIxBound$fExceptionIterationException$fShowIterationException$fExceptionMatrixException$fShowMatrixException$fExceptionOperandSizeMismatch$fShowOperandSizeMismatch $fExceptionOutOfBoundsIndexError$fShowOutOfBoundsIndexError$fExceptionInputError$fShowInputError$fExceptionPartialFunctionError$fShowPartialFunctionError$fEqPartialFunctionError$fEqInputError$fEqOutOfBoundsIndexError$fEqOperandSizeMismatch$fEqMatrixException$fEqIterationExceptionIterationConfigIterConfnumIterationsMaxprintDebugInfo iterationView printDebugIO modifyUntil modifyUntilMuntilConvergedG0untilConvergedGuntilConvergedGMmodifyInspectGuardedmodifyInspectGuardedMSpVectorSVsvDimsvDataspySVnzSV sizeStrSVfoldlWithKeySVfoldlWithKeySV'dotSdotSSafezeroSV singletonSVei mkSpVector mkSpVector1mkSpVRmkSpVCfromListDenseSVspVectorDenseIxspVectorDenseLoHi oneHotSVUoneHotSVonesSVzerosSVconstv fromVectortoVector toVectorDenseinsertSpVectorinsertSpVectorSafe fromListSVcreatevvrvctoListSV toDenseListSVifoldSVlookupSVlookupDefaultSV lookupDenseSVtailSVheadSVtakeSVdropSVrangeSVconcatSVfilterSV ifilterSV sparsifySV orthogonalSV$fSpContainerSpVector$fSparseSpVector$fHasDataSpVector$fFiniteDimSpVector$fFoldableSpVector $fSetSpVector$fFunctorSpVector$fShowSpVector $fEqSpVector insertRowWith insertRow insertColWith insertCol outerProdSV>< diagonalSMsvToSMtoSV lookupRowSM extractRow extractColextractVectorDenseWithextractRowDenseextractColDenseextractDiagDense extractSubRowextractSubRow_RK extractSubColextractSubCol_RK fromRowsL fromColsLtoRowsLtoColsL fromColsV fromRowsV$fPrintDenseSpMatrix$fPrintDenseSpMatrix0$fPrintDenseSpVector$fPrintDenseSpVector0LinSolveMethodGMRES_CGNE_BCG_CGS_ BICGSTAB_conditionNumberSMhhReflgivensqreigsQR eigsArnoldicholluarnoldidiagPartitionsluSolve triLowerSolve triUpperSolvepinv linSolve0$fShowBICGSTAB $fShowCGS $fShowBCG $fShowCGNE$fEqCGNE$fEqBCG$fEqCGS $fEqBICGSTAB$fEqLinSolveMethod$fShowLinSolveMethodbase Data.Complex magnitudeghc-prim GHC.Classes<=GHC.Numabs withDefault with2Defaults intersectWithintersectWithD unionWithDlift2sndsafemaxTupminTupindexedindexed2foldrMap foldlStrictifoldrUBLB unionWithintersectWith0 unionWith0indexed'inBounds inBounds2 inBounds0 inBounds02head'tail'LexOrd RowsFirst ColsFirstLexIxIxColIxRowColsRows PPrintOptionsprdefRprdefCprintDNprintCN printNpadprepDprepCspacesPPOpts pprintLen pprintDecpprintColWidth PrintDensenewlinecommasreaimStreamcsPtrV MergeStateMergeLMergeRMergeLeftEndedMergeRightEnded MergeStartStepYieldSkipDonenumLoop numLoopST' numLoopST''intersectWithCompareunionWithComparesortWith sortWith3 sortByFst3 sortBySnd3fst3snd3third3tail3mapFst3mapSnd3 mapThird3lift2mergeStreamsWith isOrderedVmergeStreamsWith0unionWithM_preallocSMVectorSMVsmvDimsmvIxsmvValfromListfromListOverwriteindex unionWithSMVSVectorsvIxsvVal fromDenseintersectWithM unionWithMthawfreezebothheadTail$fHasDataSVector$fTraversableSVector$fFoldableSVector$fFunctorSVector $fShowSVectorSListsldotslsum$fAdditiveGroupSListSLunSLemptySLconsSLheadSLtoListl1l2$fInnerSpaceSList$fVectorSpaceSListIntMunIMemptysize singleton filterWithKeyinsertfilterIlookuplookupLT foldlWithKey foldlWithKey' mapWithKeykeysmapKeysunionfindMinfindMax!mkImmkImC$fAdditiveGroupIntM $fSetIntM $fIsListIntM insertIM2 lookupIM2 lookupWD_IM fromListIM2 ifoldlIM2' ifoldlIM2foldlIM2 transposeIM2 ifilterIM2 filterSubdiagsubdiagIndicesmapIM2imapIM2 mapKeysIM2countSubdiagonalNZrpairs mapColumnIM2toCSCfromCSC extractColCSC transposeCSC CscMatrixCscMcscNrowscscNcolscscNzcscRowIx cscColPtrcscValfromCSC0extractDiagSubdiagCSC cscToGraph$fSparseCscMatrix$fHasDataCscMatrix$fFiniteDimCscMatrix$fShowCscMatrix$fFoldableCscMatrix$fFunctorCscMatrix CsbMatrixbBinbCoordsblockIxBlockCSBcsbNrowscsbNcolscsbBetacsbVal csbBlkPtrcsbRowIxcsbColIx csbParams consBlockElem consBlocks modifyUntil' onRangeSparseonRangeSparseMcombxrelResdiffSqLrelTolSunS1unS2ConvergenceStatusBufferNotReady Converging Converged Diverging NotConverged modifyUntilM' unfoldZipM0 unfoldZipMqdiverg norm2DiffliftS1s0ic1$fShowIterationConfigGHC.ListtakedropresizeSV mapKeysSVvecMatSDmatVecSDshowNz toDenseRowprdRprdC printDenseSM printDenseSM0printDenseSM0rprintDenseSM0c printDenseSVprintDenseSV0rprintDenseSV0c printDenseSV0 TriMatrixreachableFromRHSinitializeSolnappendIMlookupWDTLeafBranchTMunTM flattenForesttlUpdateSubdiagg0t0g1 emptyIMSLemptyTMluConfiguSteplStepfillSMtesttm0tm2tm4tm9tmc4nextnext'labelElt eigRayleigh gklBidiagTFQMR_xTfq_wTfq_uTfq_vTfq_dTfq_mTfq_tauTfq _thetaTfq_etaTfq_rhoTfq _alphaTfq tfqmrInit tfqmrStep $fShowTFQMRNum'* givensCoef jacobiPreilu0PremSsorPregmresBICGSTAB _xBicgstab _rBicgstab _pBicgstabCGS_x_r_p_uBCG_xBcg_rBcg_rHatBcg_pBcg_pHatBcgCGNE_xCgne_rCgne_pCgnehhMathypothhVlu'tvc4tmc5tmc6 luSolveConfigtriLowerSolve0triUpperSolve0cgneInitcgneStepbcgInitbcgStepcgsInitcgsStep bicgsInit bicgstabStep