úÎ760     stableerkokl@gmail.com Safe-InferredIA sparse matrix is essentially an int-map containing sparse row-vectors:  The first element, n@, is the number of rows in the matrix, including those with all 0 elements. ( The matrix is implicitly assumed to be nxn, indexed by keys (0, 0) to  (n-1, n-1). E When constructing a sparse-matrix, only put in rows that have a non-0! element in them for efficiency. o Note that you have to give all the non-0 elements: Even though the matrix must be symmetric for the algorithm 6 to work, the matrix should contain all the non-07 elements, not just the upper (or the lower)-triangle. 2 Make sure the keys of the int-map is a subset of  [0 .. n-1]X, both for the row-indices and the indices of the vectors representing the sparse-rows. ,A sparse vector containing elements of type a$. Only the indices that contain non-0 elements should be given N for efficiency purposes. (Nothing will break if you put in elements that are 0's, it's just not as efficient.) $Look-up a value in a sparse-vector. $Look-up a value in a sparse-matrix. &Multiply a sparse-vector by a scalar. &Multiply a sparse-matrix by a scalar. Add two sparse vectors. Subtract two sparse vectors. #Dot product of two sparse vectors. \Multiply a sparse matrix (nxn) with a sparse vector (nx1), obtaining a sparse vector (nx1). GNorm of a sparse vector. (Square-root of its dot-product with itself.) )Conjugate Gradient Solver for the system Ax=b. See:  6http://en.wikipedia.org/wiki/Conjugate_gradient_method. NB. Assumptions on the input:  The A, matrix is symmetric and positive definite.  All non-0W rows are present. (Even if the input is assumed symmetric, all rows must be present.)  The indices start from 0 and go consecutively up-to n-1 . (Only non-0 value/row - indices has to be present, of course.) kFor efficiency reasons, we do not check that these properties hold of the input. (If these assumptions are U violated, the algorithm will still produce a result, but not the one you expected!) We perform either 10^6D iterations of the Conjugate-Gradient algorithm, or until the error  factor is less than 1e-10?. The error factor is defined as the difference of the norm of T the current solution from the last one, as we go through the iterative solver. See   nhttp://en.wikipedia.org/wiki/Conjugate_gradient_method#Convergence_properties_of_the_conjugate_gradient_method C for a discussion on the convergence properties of this algorithm. 9The solver can throw an error if it does not converge by 10^6- iterations. This is typically an indication R that the input matrix is not well formed, i.e., not symmetric positive-definite. IThe Conjugate-gradient algorithm. Our implementation closely follows the  one given here:  Mhttp://en.wikipedia.org/wiki/Conjugate_gradient_method#Example_code_in_Matlab LDisplay a solution in a human-readable form. Needless to say, only use this E method when the system is small enough to fit nicely on the screen.  *The seed for the random-number generator. The A sparse matrix (nxn). The b sparse vector (nx1). The x sparse matrix (nx1 ), such that Ax = b. 9Precision: Use this many digits after the decimal point. The A matrix, nxn The b matrix, nx1 The x matrix, nx1, as returned by  , for instance.          conjugateGradient-2.1Math.ConjugateGradientSMSVlookupSVlookupSMsMulSVsMulSMaddSVsubSVdotSVmulSMVnormSVsolveCG showSolutioncg