1.0.4 • Published 9 years ago

# solve-banded v1.0.4

4
MIT
Repository
github
Last release
9 years ago

## solve-banded

Solve a system of banded linear equations

## Introduction

This module accepts javascript Arrays or typed arrays representing the bands of a banded matrix and computes the solution using the Thomas Algorithm. A system with one subdiagonal and two superdiagonal bands, for example, looks like:

The solver will fail if the matrix is singular and may not succeed if the matrix is not diagonally dominant. If the solver fails, it will log a console message and return false. Note that the solver accepts a stride and offset for the input/output vector (`x`, below), so that a system can be solved in-place in an ndarray. The coefficient matrix does not currently accept strides or offsets and must be passed as individual vectors.

## Example

Consider the solution of the tridiagonal system

``````var solveBanded = require('solve-banded')

var e = [4, 25, -5]

solveBanded([[0, -1, 2], [2, 7, -3], [1, 4, 0]], 1, 1, e, 3)

console.log(e)
// => e = [ 1, 2, 3 ]``````

## Installation

``\$ npm install solve-banded``

## API

#### `require('solve-banded')(diagonals, nsub, nsup, x, nx [, ox = 0 [, sx = 1]])`

Arguments:

• `diagonals`: an array of diagonal bands, starting with with the subdiagonal-most band (a in the example matrix above) and proceeding to the superdiagonal-most band (d in the example matrix above). Each vector must be a javascript `Array` or typed array of length `nx`.
• `nsub`: an integer representing the number of subdiagonal bands, excluding the diagonal.
• `nsup`: an integer representing the number of superdiagonal bands, excluding the diagonal.
• `x`: a javascript `Array` or typed array of length `nx` representing the known vector (e in the example matrix above). On successful completion, this vector will contain the solution.
• `nx`: an integer representing the number of equations, i.e. the length of `x`.
• `ox` (optional): an integer representing the offset of data in `x`. If not provided, assumed equal to zero.
• `sx` (optional): an integer representing the stride of data in `x`. If not provided, assumed equal to one.

Returns: True on successful completion, false otherwise.

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago