Socket
Book a DemoInstallSign in
Socket

conjugate-gradient

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

conjugate-gradient

Conjugate gradient solver

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

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-gradient

Example

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

  • A is a symmetric positive definite matrix represented as a CSRMatrix
  • b is an array of length n
  • x0 is an optional initial guess for the solution to the equation. If specified, the result of the solution will also get stored in this array
  • tolerance is a cutoff tolerance for the solution. (Default is 1e-5)
  • max_iter is 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

Keywords

linear

FAQs

Package last updated on 03 Apr 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts