Skip to content

๐Ÿ”ข A simple linear solver for real and complex numbers in WebAssembly.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE_APACHE
MIT
LICENSE_MIT
Notifications You must be signed in to change notification settings

felipemarkson/axb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Axb

๐Ÿ”ข A simple linear solver for real and complex numbers in WebAssembly.

๐Ÿ› ๏ธ Build

Requiriments

For tests:

How to build

Clone this repository, and then run the command bellow in the repository folder:

wasm-pack build --target web

This command will build the binaries and the JavaScript files on ./pkg/.

๐Ÿ”ฌ Test

wasm-pack test --node

๐Ÿš€ Usage

You can find an exemple of usage in ./example/.

Defining Matrices and Vectors

The matrices are defined as below:

//| 1.0   0.0 |
//| 0.0   1.0 |
const eye2x2 = {
    nrow: 2,
    ncol: 2,
    elements: [
        {
            row: 0,
            col: 0,
            // If the element is real:
            value: 1.0,
            // If the element is complex (a + jb):
            // value: (a, b),
        },
        {
            row: 1,
            col: 1,
            // If the element is real:
            value: 1.0,
            // If the element is complex (a + jb):
            // value: (a, b),
        }
    ]
}

Vectors are defined as a Matrix with ncols: 1.

NOTE: You only need to define non-zero values.

NOTE: If some of the matrix's element is complex, all elements must be defined as complex.

Solving linear systems

Lets defining A a nxn matrix b a vector nx1. The linear system is defined by Ax = b.

After build the Axb, we can solve this linear system as below:

import init, { solve, complex_solve } from 'path/to/axb.js';
async () -> {
    const A = //...
    const b = //...
    await init();
    const x = solve(A, b); // For real elements
    // const x = complex_solve(A, b); // For complex elements
}()

The returns of these functions are Matrices as well.

NOTE: A and b must have the same type of elements (real or complex).

๐Ÿ“– License

Axb is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE_APACHE and LICENSE_MITfor details.

About

๐Ÿ”ข A simple linear solver for real and complex numbers in WebAssembly.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE_APACHE
MIT
LICENSE_MIT

Stars

Watchers

Forks