japaric-archived / linalg.rs

[INACTIVE]
Apache License 2.0
29 stars 1 forks source link

Status

This project is currently INACTIVE as Rust doesn't have the required features to realize my vision. Until at least something like custom fat pointers land in the compiler I won't be working on this.

You might be interested in ndarray which implements an N dimensional array with several "view" operations.

-- @japaric, 2016-05-02


PSA Development is now happening on the ng branch.

linalg.rs

Linear algebra library with BLAS and LAPACK acceleration.

Features

API documentation

Examples

C dependencies

The BLAS and LAPACK libraries must be available. In Ubuntu, you can install the reference implementations with the following commands:

$ sudo apt-get install libblas-dev
$ sudo apt-get install liblapack-dev

Though an optimized BLAS package like OpenBLAS is highly recommend.

Improving operator sugar

If you saw the quick reference then you know that this library is not as nice to use as Numpy or Octave due to the lack of operator sugar.

Solving this issue requires changes in the compiler, here's a list with a brief description of each change and the sugar it enables:

let x = &A[i, j];  // === Index::index(&A, (i, j));

let y = B[i, j];  // === *Index::index(&B, (i, j));
// &Row, &mut Col, &SubMat are fat pointers like &[T]

let row: &Row = &A[i, ..];  // === Index::index(&A, (i, ..));

let col: &mut Col = &mut A[.., j];  // === IndexMut::index_mut(&mut A, (.., j));

let submat: &SubMat = &A[a..b, c..d];  // === Index::index(&A, (a..b, c..d));
A[i, ..] += &B[j, ..];  // === AddAssign::add_assign(&mut A[i, ..], &B[j, ..]);

A[a..b, c..d] *= 2;  // === MulAssign::mul_assign(&mut A[a..b, c..d], 2);
A[1, ..] = 0;  // === IndexSet::index_set(&mut A[1, ..], 0);

A[..2, ..] = &B[2.., ..];  // === IndexSet::index_set(&mut A[..2, ..], &B[2.., ..]);

Contributing

Reporting bugs, missing operations and feature requests

The best way to contribute to this library is by using it and reporting any problem you encounter.

If you hit a debug_assert!, that's a bug. Please open an issue in the issue tracker. Note that assert!s are normal and indicate a programmer errors like index out of bounds or mismatched dimensions.

If you get a wrong result from an operation, like A * A.inv() not being equal to the identity matrix, that's a bug too.

If some operation doesn't compile and you think it should (but read the Notes about operators first) that's a "missing operation" and should be reported.

If you need some feature from the LAPACK/BLAS libraries that's not currently exposed, open a feature request in the issue tracker.

Unit tests

Ideally all the core functionality should be tested, but the current test suite is not that extensive. There's a list of missing unit tests here, help would be appreciated.

Examples

If you ported some (small) program from Numpy/Octave to linalg, consider submitting it as a example.

Benchmarks

If you have done any measurements between linalg and other linear algebra libraries (in any language), Let me know how linalg performs, specially if measurements indicate that linalg is slower.

Similar/related work

License

linalg.rs is dual licensed under the Apache 2.0 license and the MIT license.

See LICENSE-APACHE and LICENSE-MIT for more details.