dendritic_ndarray/lib.rs
1
2
3//! # Dendritic NDArray Crate
4//!
5//! This crate is the numerical computing crate to work with N Dimensional values.
6//! The operations for this numerical computing library are broken down by aggregate, binary, scalar and unary operations.
7//! This crate serves as the base depedencies for most numerical computing for all the machine learning algorithms dendritic has to offer
8//!
9//! ## Features
10//! - **NDArray**: General NDArray structure that can work with generic values.
11//! - **Shape**: Shape structure for representing dimension of N Dimensional value
12//! - **Ops**: Operations broken down into different categories supported by the NDArray module
13//!
14//! ## Supported operation types
15//! Currently the numerical operations are only supported for `f64` types. This will change in future releases.
16
17//! ## Binary Operations Example Usage
18//! These are some examples of using the `dendritic_ndarray` create with some basic operations
19//! ```rust
20//! use dendritic_ndarray::ndarray::NDArray;
21//! use dendritic_ndarray::ops::*;
22//!
23//! fn main() {
24//! // Create 2 instance of ndarrays with a shape of (2,3) for testing binary operations
25//! let x: NDArray<f64> = NDArray::array(vec![2, 3], vec![0.0,0.0,1.0,1.0,2.0,2.0]).unwrap();
26//! let y: NDArray<f64> = NDArray::array(vec![2, 3], vec![0.0,0.0,1.0,1.0,2.0,2.0]).unwrap();
27//!
28//! // perform add operation
29//! let add_result : NDArray<f64> = x.add(y).unwrap();
30//! // save result to json file
31//! add_result.save("name_of_saved_ndarray").unwrap();
32//! // load result back to new ndarray
33//! let loaded = NDArray::load("name_of_saved_ndarray").unwrap();
34//! }
35//! ```
36
37
38//! ## Unary Operations Example Usage
39//! These are some examples of using the `dendritic_ndarray` with the unary operations.
40//! Unary operations involve transoforming or modifying the contents of an ndarray and then returning the transformed result.
41//! ```rust
42//! use dendritic_ndarray::ndarray::NDArray;
43//! use dendritic_ndarray::ops::*;
44//!
45//! fn main() {
46//! // Create instance of ndarray, multiply by f64 scalar value
47//! let x: NDArray<f64> = NDArray::array(vec![2, 3], vec![0.0,0.0,1.0,1.0,2.0,2.0]).unwrap();
48//!
49//! // perform transpose operation
50//! let y : NDArray<f64> = x.transpose().unwrap(); // will return result with shape (3, 2)
51//! }
52//! ```
53
54
55//! ## Scalar Operations Example Usage
56//! These are some examples of using the `dendritic_ndarray` with the scalar operations.
57//! Scalar operations involve an `ndarray` and a scalar value like an `f64`.
58//! ```rust
59//! use dendritic_ndarray::ndarray::NDArray;
60//! use dendritic_ndarray::ops::*;
61//!
62//! fn main() {
63//! // Create instance of ndarray, multiply by f64 scalar value
64//! let x: NDArray<f64> = NDArray::array(vec![2, 3], vec![0.0,0.0,1.0,1.0,2.0,2.0]).unwrap();
65//! let y: f64 = 10.0;
66//!
67//! // perform add operation
68//! let scalar_result : NDArray<f64> = x.scalar_add(y).unwrap();
69//! }
70//! ```
71
72
73//! ## Aggregate Operations Example Usage
74//! These are some examples of using the `dendritic_ndarray` with the aggregate operations.
75//! Aggregate operations reduce the dimension or result of an operation on an ndarray.
76//! An example of this is statistical operations like taking the average or summing all values.
77//! ```rust
78//! use dendritic_ndarray::ndarray::NDArray;
79//! use dendritic_ndarray::ops::*;
80//!
81//! fn main() {
82//! // Create instance of ndarray, multiply by f64 scalar value
83//! let x: NDArray<f64> = NDArray::array(vec![2, 3], vec![0.0,0.0,1.0,1.0,2.0,2.0]).unwrap();
84//!
85//! // perform add operation
86//! let x_avg: f64 = x.avg();
87//! }
88//! ```
89//! ## Disclaimer
90//! The dendritic project is a toy machine learning library built for learning and research purposes.
91//! It is not advised by the maintainer to use this library as a production ready machine learning library.
92//! This is a project that is still very much a work in progress.
93pub mod ndarray;
94pub mod shape;
95pub mod ops;
96
97
98