Package Exports
- conjugate-gradient
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (conjugate-gradient) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
conjugate-gradient
Solves sparse symmetric positive definite linear systems. These problems arise in many physical applications, like linear elasticity, heat transfer and other diffusion based transport phenomena.
This code implements the conjugate gradient method using a Jacobi preconditioner.
Install
npm install conjugate-gradientExample
var pcg = require("conjugate-gradient")
, CSRMatrix = require("csr-matrix")
//Create a matrix
var A = CSRMatrix.fromDense([[-2, 1, 0],
[ 1,-2, 1],
[ 0, 1,-2]])
//Create input vector
var B = new Float64Array([1, 0, 0])
//Solve equation:
//
// A x = B
//
console.log(pcg(A, b))require("conjugate-gradient")(A, b[, x0, tolerance, max_iter])
Solves the equation Ax = b by conjugate gradient
Ais a symmetric positive definite matrix represented as a CSRMatrixbis an array of length nx0is an optional initial guess for the solution to the equation. If specified, the result of the solution will also get stored in this arraytoleranceis a cutoff tolerance for the solution. (Default is 1e-5)max_iteris the maximum number of iterations to run the solver. (Default is min(n, 20))
Returns An array encoding the solution to the equation Ax = b
Credits
(c) 2013 Mikola Lysenko. MIT License