Installation
Getting started with single-algebra is straightforward. This page guides you through the installation process and basic setup.
Adding single-algebra to Your Project
Add single-algebra to your Rust project by including it in your Cargo.toml
file:
[dependencies]
single-algebra = "0.7.0"
By default, this includes the core functionality with minimal dependencies. To enable additional features, specify them explicitly:
[dependencies]
single-algebra = { version = "0.7.0", features = ["lapack", "faer"] }
See the Features page for a complete list of available features.
Basic Usage
Once installed, you can import single-algebra in your Rust code:
// Import the entire library
use single_algebra::*;
// Or import specific components
use single_algebra::sparse::MatrixSum;
use single_algebra::dimred::pca::dense::PCABuilder;
use single_algebra::similarity::CosineSimilarity;
Verifying Installation
Create a simple example to verify your installation:
use single_algebra::sparse::{MatrixSum};
use nalgebra_sparse::{CooMatrix, CsrMatrix};
fn main() -> anyhow::Result<()> {
// Create a simple sparse matrix
let coo = CooMatrix::try_from_triplets(
3, 3,
vec![0, 1, 2],
vec![0, 1, 2],
vec![1.0, 2.0, 3.0]
).unwrap();
let csr: CsrMatrix<f64> = (&coo).into();
// Calculate column sums
let col_sums: Vec<f64> = csr.sum_col()?;
println!("Column sums: {:?}", col_sums);
Ok(())
}
Available Features
single-algebra provides several optional features that can be enabled based on your needs:
- lapack: Enables LAPACK integration for numerical linear algebra via
nalgebra-lapack
with OpenBLAS - faer: Enables Faer for numerical linear algebra (a pure Rust implementation)
- simba: Enables SIMD acceleration for statistics
- smartcore: Integrates with the smartcore machine learning library
To enable multiple features:
[dependencies]
single-algebra = { version = "0.7.0", features = ["lapack", "faer", "simba"] }
Platform Support
single-algebra is designed to work on all platforms supported by Rust, including:
- Linux
- macOS
- Windows
- Other Unix-like systems
Certain features that depend on external libraries (like LAPACK) may have additional platform-specific requirements. See the Requirements page for details.
Release Channels
single-algebra follows semantic versioning:
- Stable releases: Use the latest version number (e.g.,
0.7.0
) - Development: For the latest development version, you can use a Git dependency:
[dependencies]
single-algebra = { git = "https://github.com/SingleRust/single-algebra.git", branch = "main" }
Updating
To update to the latest version of single-algebra, modify the version number in your Cargo.toml
:
[dependencies]
single-algebra = "0.7.0" # Current latest version
Or run cargo update
to update within your specified version constraints.
For questions or issues with installation, please open an issue on the GitHub repository.