项目作者: numeric-rust

项目描述 :
N-dimensional matrix class for Rust
高级语言: Rust
项目地址: git://github.com/numeric-rust/numeric.git
创建时间: 2015-06-22T15:13:06Z
项目社区:https://github.com/numeric-rust/numeric

开源协议:MIT License

下载


Crates.io

Numeric Rust

General-purpose N-dimensional matrix class for Rust. It links to OpenBLAS and
LAPACK to make tensor operations fast (such as matrix multiplications and
linear solvers). It utilizes Rust’s move semantics as much as possible to avoid
unnecessary copies.

Documentation

Features

Some of the completed and planned features:

  • Element-wise addition, subtraction, multiplication, division
  • Matrix multiplication and scalar product
  • Indexing
  • Slicing
  • Generic (anything from Tensor<bool> to Tensor<f64>)
  • Mathematical functions
  • Linear solver
  • Basic random number generation
  • Creation macro
  • Updating slices
  • Saving/loading HDF5
  • Strided slices
  • Broadcasted axes
  • Basic support for complex numbers
  • Singular Value Decomposition
  • Matrix inverse

Recent progress is summarized in CHANGELOG.md. For planned
features, take a look at TODO.md.

Example

  1. #[macro_use(tensor)]
  2. extern crate numeric;
  3. use numeric::Tensor;
  4. fn main() {
  5. let a: Tensor<f64> = Tensor::range(6).reshape(&[2, 3]);
  6. let b = tensor![7.0, 3.0, 2.0; -3.0, 2.0, -5.0];
  7. let c = tensor![7.0, 3.0, 2.0];
  8. let d = &a + &b; // a new tensor is returned
  9. println!("d = {}", d);
  10. let e = a.dot(&c); // matrix multiplication (returns a new tensor)
  11. println!("e = {}", e);
  12. let f = a + &b; // a is moved (no new memory is allocated)
  13. println!("f = {}", f);
  14. // Higher-dimensional
  15. let g: Tensor<f64> = Tensor::ones(&[2, 3, 4, 5]);
  16. println!("g = {}", g);
  17. }

Output:

  1. d =
  2. 7 4 4
  3. 0 6 0
  4. [Tensor<f64> of shape 2x3]
  5. e =
  6. 7 43
  7. [Tensor<f64> of shape 2]
  8. f =
  9. 7 4 4
  10. 0 6 0
  11. [Tensor<f64> of shape 2x3]
  12. g =
  13. ...
  14. [Tensor<f64> of shape 2x3x4x5]

Contribute

We love pull requests and there are tons of things to work on for this project.
If you want suggestions for contributions, check out TODO.md (a
non-exhaustive list of what would be useful additions). Add your name to the
CONTRIBUTORS.md file as part of your PR, no matter how small
it may seem.

Acknowledgements

Numeric Rust is primarily inspired by Numpy and borrows heavily from that
project. Even the name is a play on Numeric Python. Another source of
some inspiration is Torch7.