Peroxide
Rust numeric library with R Syntax.
Latest README version
Corresponds with 0.5.0
.
Usage
Initial Import
extern crate peroxide;
use *;
Vec<f64> Declaration
# R
a =
b = # (=c(1,3,5))
// Peroxide
extern crate peroxide;
use *;
Matrix Declaration
# R
a =
// Peroxide (All belows are same)
extern crate peroxide;
use *;
# R
a =
# [,1] [,2]
# [1,] 1 2
# [2,] 3 4
// Peroxide
extern crate peroxide;
use *;
// c[0] c[1]
// r[0] 1 2
// r[1] 3 4
Concatenate
1. Vector + Vector => Vector
# R
a =
b =
c = # c(1,2,3,4,5,6)
// Peroxide
extern crate peroxide;
use *;
2. Matrix + Matrix => Matrix
# R
# cbind
a =
b =
c =
# [,1] [,2] [,3]
#[1,] 1 3 5
#[2,] 2 4 6
# rbind
a =
b =
c =
# [,1] [,2]
#[1,] 1 2
#[2,] 3 4
#[3,] 5 6
// Peroxide
extern crate peroxide;
use *;
Matrix operation
- If you want to do multiple operations on same matrix, then you should use
clone
because Ruststd::ops
consume value.
# R
a =
b =
// Peroxide
extern crate peroxide;
use *;
LU Decomposition
- Peroxide uses complete pivoting LU decomposition. - Very stable.
- Also there are lots of error handling for LU, so, you should use
Option
// Peroxide
extern crate peroxide;
use *;
Determinant
- Determinant is implemented using by LU decomposition (O(n^3))
// Peroxide
extern crate peroxide;
use *;
Inverse
- Inverse is also implemented using by LU decomposition
- To handle singularity, output type is
Option<Matrix>
- To obtain inverse, you should use
unwrap
or pattern matching
- To obtain inverse, you should use
// Peroxide
extern crate peroxide;
use *;
Extract Column or Row
# R
a =
//Peroxide
extern crate peroxide;
use *;
Functional Programming
// Peroxide
extern crate peroxide;
use *;
// Results
//
// c[0] c[1]
// r[0] 2 3
// r[1] 4 5
//
// c[0] c[1]
// r[0] 0 1
// r[1] 2 3
//
// c[0] c[1]
// r[0] 2 4
// r[1] 6 8
Write to CSV
You can write matrix to csv by two ways.
// Peroxide
extern crate peroxide;
use *;
use process; // for error handling
Read from CSV
You can read matrix with error handling
// Peroxide
extern crate peroxide;
use *;
use process;
Version Info
To see Release.md