Skip to content

Commit

Permalink
rest of the owl
Browse files Browse the repository at this point in the history
  • Loading branch information
sarah-quinones committed Jan 13, 2025
1 parent 9f2e6f7 commit 1821399
Show file tree
Hide file tree
Showing 56 changed files with 1,028 additions and 585 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ on:
push:
branches:
- main
- dev
- refactor-3
pull_request:

name: Run Tests
Expand All @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
toolchain:
- 1.81.0
- 1.84.0
os:
- ubuntu-latest
- windows-latest
Expand All @@ -32,10 +32,11 @@ jobs:

- uses: Swatinem/rust-cache@v2

- name: MSRV 1.81.0
- name: MSRV 1.84.0
run:
cd ./faer-traits &&
cargo check &&
cd ./faer-entity &&
cd ../faer &&
cargo check

nostd:
Expand All @@ -45,7 +46,7 @@ jobs:
fail-fast: false
matrix:
toolchain:
- nightly-2024-08-02
- nightly-2025-01-08
os:
- ubuntu-latest
- windows-latest
Expand All @@ -65,7 +66,7 @@ jobs:
- name: nostd
run:
cd ./faer-no-std-test &&
cargo run
cargo run --profile nostd

testing:
name: testing-${{ matrix.toolchain }}-${{ matrix.os }}
Expand Down Expand Up @@ -98,7 +99,7 @@ jobs:
uses: taiki-e/install-action@cargo-llvm-cov

- name: Collect coverage data
run: cargo llvm-cov nextest --features=unstable --lcov --output-path lcov.info
run: cd faer && cargo llvm-cov nextest --features=unstable --lcov --output-path ../lcov.info

- name: Upload coverage data to codecov
uses: codecov/codecov-action@v3
Expand Down
121 changes: 121 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# 0.19
- Support matrix-scalar multiplication/division without the `Scale` wrapper for `f32`/`f64`.
- Implemented conjugate gradient, BiCGSTAB, and LSMR iterative solvers (currently gated by the `unstable` feature).
- Implemented Hermitian matrix pseudoinverse implementation. Thanks @lishen_ for the contribution.
- Implemented column and row mean and variance in `faer::stats`.
- Added more iterator and parallel iterator functions (`MatRef::[col|row]_partition`, `MatRef::par_[col|row]_partition`, etc.).
- Added `full` and `zeros` constructors to owned Col, Row, and Matrix ([issue-125](https://github.com/sarah-ek/faer-rs/issues/125)).
- Added `shape` function to return both the row and the column count of a matrix.
- Added several missing associated functions from the mut and owning variants of matrices.
- Implemented `core::iter::{Sum, Product}` for `c32` and `c64`.
- Sparse Cholesky can now be used with user-provided permutations.
- Simplified matrix constructors, adding a variant with a `_generic` prefix for the old behavior.
- LDLT and Bunch-Kaufman decompositions now stores the diagonal blocks instead of their inverses. This helps avoid infinities and NaNs when dealing with singular matrices.
- Integrated `nano-gemm` as a backend for small matrix multiplication.
- Significant performance improvements for small LLT and LDLT decompositions.

# 0.18
- Refactored the project so that `faer` contains all the core and decomposition implementations. `faer-{core,cholesky,lu,qr,svd,evd,sparse}` are now deprecated and will no longer be updated.
- Improved the multithreaded performance of the Eigenvalue decomposition for large matrices.
- Decomposition solve functions now accept column vectors as well as matrices.
- Implemented the L1 norm, and the squared L2 norm.
- Implemented conversions from sparse to dense matrices, by calling `mat.to_dense()`.
- Sparse matrices now support duplicated entries. Note that `faer` will not add duplicated entries to a matrix unless the opposite is explicitly mentioned in the function documentation. `faer` also will deduplicate entries when created with `Sparse{Col,Row}Mat::try_new_from_indices` and other similar functions.
- Implemented conversions from unsorted to sorted sparse matrices by calling `mat.to_sorted()` (or `mat.sort_indices()` for owned matrices).
- Implemented `{Col,Row}::try_as_slice[_mut]` functions that return data as a slice if it is contiguous.
- Implemented `.for_each_with_index` and `.map_with_index` for the matrix zipping API, which passes the matrix row and column indices as well as the values.
- Added `rand` support for randomly generating matrices in the `faer::stats` module, as well as for `faer::complex_native::{c32,c64}`.
- Implemented a pseudoinverse helper for the high level SVD and thin SVD decompositions.

# 0.17
- Implemented sparse matrix arithmetic operators (other than sparse-sparse matrix multiplication), and added mutable sparse views as well as owning sparse matrix containers.
- Implemented `try_from_triplets` for sparse matrices.
- Re-exported subcrates in `faer::modules`.
- Improved performance of the SVD decomposition for small matrices.
- Implemented `col!`, `row!` and `concat!` macros. Thanks @DeliciousHair for the contribution.
- Implemented more `c32/c64` operations. Thanks @edyounis for the contribution.
- Implemented the Kronecker product in `faer_core`. Thanks @edyounis for the contribution.
- Implemented (de)serialization of `Mat`. Thanks @cramt for the contribution.

# 0.16
- Implemented the index operator for row and column structures. Thanks @DeliciousHair for the contribution.
- Exposed a few sparse matrix operations in the high level API.
- Implemented sparse LU and QR, and exposed sparse decompositions in the high level API.
- Better assertion error messages in no_std mode.

# 0.15
- Implemented initial API of `Row`/`RowRef`/`RowMut` and `Col`/`ColRef`/`ColMut` structs for handling matrices with a single row or column.
- Implemented `[Mat|Col|Row]::norm_l2` and `[Mat|Col|Row]::norm_max` for computing the L2 norm of a matrix or its maximum absolute value.
- Fixed several bugs in the eigenvalue decompositions. Special thanks to @AlexMath for tracking down the errors.
- Updated `zipped!` macro API, which now requires a matching `unzipped!` for matching the closure arguments.
- Removed the limitation on the number of matrices that can be passed to `zipped!`.
- Added a `zipped!(...).map(|unzipped!(...)| { ... })` API to allow mapping a zipped pack of matrices and returns the result as a matrix.
- Updated `polars` dependency to 0.34.
- Speed improvements for complex matrix multiplication on AMD cpus.
- New SIMD functions in the Entity trait for aligned loads and stores.
- Renamed multiple methods such as `MatMut::transpose` to `MatMut::transpose_mut`.

# 0.14
- Implemented sparse data structures in `faer_core::sparse`.
- Implemented sparse Cholesky decompositions, simplicial and supernodal. Only the low level API is currently exposed in `faer-sparse`.
- Implemented dynamic regularization for the Bunch-Kaufman Cholesky decomposition.
- Implemented diagonal wrappers that can be used to interpret a matrix as a diagonal matrix, using `{MatRef,MatMut}::diagonal` and `{MatRef,MatMut}::column_vector_as_diagonal`.
- Implemented matrix multiplication syntax sugar for diagonal wrappers, and permutation matrices.
- Implemented `compute_thin_r` and `compute_thin_q` in `faer::solvers::{Qr,ColPivQr}`.
- Implemented initial SIMD support for aarch64.

# 0.13
- Implemented the Bunch-Kaufman Cholesky decomposition for hermitian indefinite matrices.
- Implemented dynamic regularization for the diagonal LDLT.
- Support conversions involving complex values using `IntoFaerComplex`, `IntoNalgebraComplex` and `IntoNdarrayComplex`.
- Refactored the Entity trait for better ergonomics.
- `faer` scalar traits are now prefixed with `faer_` to avoid conflicts with standard library and popular library traits.
- `no_std` and `no_rayon` are now supported, with the optional features `std` and `rayon` (enabled by default).
- Performance improvements in the eigenvalue decomposition and thin matrix multiplication.

# 0.12
- Implemented matrix chunked iterators and parallel chunked iterators.
- Renamed `{Mat,MatMut}::fill_with_zero` to `fill_zeros`
- Renamed `{Mat,MatMut}::fill_with_constant` to `fill`
- More ergonomic `polars` api.
- Refactored Entity and ComplexField SIMD api.
- Switched from DynStack/GlobalMemBuffer to PodStack/GlobalPodBuffer.
- Fixed usize overflow bug in eigenvalue decomposition.

# 0.11
- High level api implemented in `faer`.
- Renamed `Mat::with_dims` to `Mat::from_fn`.
- Renamed `{Mat,MatMut}::set_zeros` to `fill_with_zero`.
- Renamed `{Mat,MatMut}::set_constant` to `fill_with_constant`.

# 0.10
- Performance improvements for small matrices.
- Simpler SVD/EVD API for fixed precision floating point types.
- Simpler math operators (+, -, *). Thanks @geo-ant and @DJDuque.
- More robust pivoted decompositions for rank deficient matrices.
- Better overflow/underflow handling in matrix decompositions, as well as non finite inputs.
- Provide control over global parallelism settings in `faer-core`.
- Various bug fixes for complex number handling.

# 0.9
- Implement the non Hermitian eigenvalue decomposition.
- Improve performance of matrix multiplication.
- Improve performance of LU decomposition with partial pivoting.

# 0.8
- Refactor the core traits for better SIMD support for non native types, using a structure-of-arrays layout.
- Implement the Hermitian eigenvalue decomposition.

# 0.7
- Add `to_owned` function for converting a `MatRef/MatMut` to a `Mat`. Thanks @Tastaturtaste
- Allow comparison of conjugated matrices
- Performance improvements for `f32`, `c32`, and `c64`
- Performance improvements for small/medium matrix decompositions
- Refactor the `ComplexField` trait to allow for non `Copy` types. Note that types other than `f32`, `f64`, `c32`, `c64` are not yet supported.

# 0.6
- Start keeping track of changes.
- Complex SVD support.
- Improve performance for thin SVD.
- Fixed an edge case in complex Householder computation where the input vector is all zeros.

21 changes: 21 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: faer-rs
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: Sarah
family-names: El Kazdadi
email: sarah.elkazdadi@gmail.com
orcid: 'https://orcid.org/0000-0002-5657-0710'
repository-code: 'https://github.com/sarah-quinones/faer-rs'
url: 'https://faer-rs.github.io/'
abstract: A high performance linear algebra library for Rust
keywords:
- math
- linear algebra
license: MIT
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ members = [
"faer-traits",
"faer",
"faer-macros",
"faer-no-std-test",
]

resolver = "2"

[profile.dev]
opt-level = 3

[profile.nostd]
inherits = "dev"
panic = "abort"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 sarah quiñones el kazdadi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# faer

[![Documentation](https://docs.rs/faer/badge.svg)](https://docs.rs/faer)
[![Crate](https://img.shields.io/crates/v/faer.svg)](https://crates.io/crates/faer)

`faer` is a Rust crate that implements low level linear algebra routines and a high level wrapper for ease of use, in pure Rust.
The aim is to provide a fully featured library for linear algebra with focus on portability, correctness, and performance.

See the [official website](https://faer-rs.github.io) and the [docs.rs](https://docs.rs/faer/latest/faer) documentation for code examples and usage instructions.

Questions about using the library, contributing, and future directions can be discussed in the [Discord server](https://discord.gg/Ak5jDsAFVZ).

# Contributing

If you'd like to contribute to `faer`, check out the list of "good first issue"
issues. These are all (or should be) issues that are suitable for getting
started, and they generally include a detailed set of instructions for what to
do. Please ask questions on the Discord server or the issue itself if anything
is unclear!

# Minimum supported Rust version

The current MSRV is Rust 1.84.0.

# Benchmarks

See [the benchmark page](https://faer-rs.github.io/bench-st.html) on the main website.

10 changes: 10 additions & 0 deletions faer-no-std-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "faer-no-std-test"
version = "0.1.0"
edition = "2021"

[dependencies]
faer = { path = "../faer", default-features = false }
libc = { version = "0.2.155", default-features = false }
libc-print = "0.1.23"

71 changes: 71 additions & 0 deletions faer-no-std-test/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#![no_std]
#![no_main]
#![feature(alloc_error_handler)]
#![feature(lang_items)]

use core::alloc::{GlobalAlloc, Layout};

/// The global allocator type.
#[derive(Default)]
pub struct Allocator;

#[cfg(windows)]
extern "C" {
fn _aligned_malloc(size: libc::size_t, align: libc::size_t) -> *mut libc::c_void;
fn _aligned_free(memblock: *mut libc::c_void);
}

unsafe impl GlobalAlloc for Allocator {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
#[cfg(not(windows))]
{
let mut mem: *mut libc::c_void = core::ptr::null_mut();
libc::posix_memalign(&mut mem, layout.align(), layout.size());
mem as *mut u8
}

#[cfg(windows)]
{
_aligned_malloc(layout.size(), layout.align()) as *mut u8
}
}

unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
#[cfg(not(windows))]
libc::free(ptr as *mut libc::c_void);

#[cfg(windows)]
_aligned_free(ptr as *mut libc::c_void)
}
}

#[panic_handler]
fn panic(panic_info: &core::panic::PanicInfo) -> ! {
let message = panic_info.message();
libc_print::libc_eprintln!("{message}");
unsafe { libc::exit(1) };
}

/// If there is an out of memory error, just panic.
#[alloc_error_handler]
fn my_allocator_error(_layout: Layout) -> ! {
panic!("out of memory");
}

#[lang = "eh_personality"]
#[no_mangle]
pub extern "C" fn rust_eh_personality() {}

/// The static global allocator.
#[global_allocator]
static GLOBAL_ALLOCATOR: Allocator = Allocator;

#[no_mangle]
pub extern "C" fn main(argc: i32, argv: *const *const u8) -> i32 {
let _ = (&argc, &argv);

let m = faer::mat![[2.0, 1.0]];
libc_print::libc_println!("{m:?}");
libc_print::libc_println!("{:?}", m.transpose() * &m);
0
}
12 changes: 7 additions & 5 deletions faer-traits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ edition = "2021"

[dependencies]
bytemuck = "1.18.0"
dyn-stack = { path = "../../dynstack" }
num-complex = "0.4.6"
pulp = { path = "../../pulp/pulp" }
reborrow = "0.5.5"
generativity = "1.1.0"
libm = "0.2.8"

dyn-stack = { version = "0.13.0", default-features = false, features = ["core-error", "alloc"] }
pulp = { version = "0.21.3", default-features = false }
faer-macros = { path = "../faer-macros" }
generativity = "1.1.0"
num-traits = "0.2.19"

num-complex = { version = "0.4.6", default-features = false }
num-traits = { version = "0.2.19", default-features = false }
Loading

0 comments on commit 1821399

Please sign in to comment.