diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e536448..c02d4752 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,14 +19,12 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: {submodules: true} - name: Install rust - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: toolchain: stable - override: true - profile: minimal components: rustfmt - name: Check formatting run: cargo fmt -- --check @@ -36,14 +34,12 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: {submodules: true} - name: Install rust - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: toolchain: stable - override: true - profile: minimal - name: Documentation run: cargo doc --all-features --workspace @@ -52,14 +48,12 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: {submodules: true} - name: Install rust - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: toolchain: stable - override: true - profile: minimal components: clippy - name: Run Clippy run: cargo clippy --workspace --all-features -- -W clippy::doc_markdown -W clippy::needless_borrow -W clippy::checked_conversions -W clippy::unseparated_literal_suffix -W clippy::unreadable_literal -W clippy::if_not_else -W clippy::needless_continue -W clippy::match_same_arms -W clippy::match_wildcard_for_single_variants -W clippy::explicit_into_iter_loop -W clippy::needless_borrow @@ -93,7 +87,7 @@ jobs: rust: stable steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: {submodules: true} - name: Install suitesparse @@ -102,11 +96,9 @@ jobs: sudo apt-get install libsuitesparse-dev - name: Install rust - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: toolchain: ${{ matrix.rust }} - profile: minimal - override: true - name: Build (exclude suitesparse) run: cargo build --verbose --workspace --exclude suitesparse_ldl_sys --exclude sprs_suitesparse_ldl --exclude sprs_suitesparse_camd --exclude suitesparse_camd_sys --exclude suitesparse_umfpack_sys --exclude sprs_suitesparse_umfpack @@ -133,17 +125,15 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: {submodules: true} - name: Install dependencies run: | sudo apt-get install libeigen3-dev libsuitesparse-dev - name: Install rust - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: toolchain: nightly - override: true - profile: minimal - name: Run benchmarks run: | cargo bench --workspace @@ -153,14 +143,12 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: {submodules: true} - name: Install rust - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: toolchain: nightly - override: true - profile: minimal - name: Run test run: | cargo test --no-default-features -p sprs @@ -170,10 +158,10 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: {submodules: true} - name: Install rust - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: toolchain: nightly override: true @@ -202,35 +190,31 @@ jobs: rust: stable steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: {submodules: true} - name: Install rust - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: toolchain: nightly - override: true - profile: minimal - name: Run tests (camd) run: | cd suitesparse_bindings/sprs_suitesparse_camd - cargo test --features suitesparse_camd_sys/static -p sprs + cargo test -p suitesparse_camd_sys --features static -p sprs - name: Run tests (ldl) run: | cd suitesparse_bindings/sprs_suitesparse_ldl - cargo test --features suitesparse_ldl_sys/static -p sprs + cargo test -p suitesparse_ldl_sys --features static -p sprs miri: name: Miri runs-on: ubuntu-20.04 steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: {submodules: false} - name: Install rust - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: toolchain: nightly - override: true - profile: minimal components: miri - name: Run test run: | diff --git a/Cargo.toml b/Cargo.toml index 88d8b2ac..ecc023fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ members = [ "sprs-benches", "sprs-tests", ] +resolver = "2" [workspace.package] rust-version = "1.64" diff --git a/sprs-ldl/src/lib.rs b/sprs-ldl/src/lib.rs index 6d75c188..880f4e81 100644 --- a/sprs-ldl/src/lib.rs +++ b/sprs-ldl/src/lib.rs @@ -1,56 +1,57 @@ -///! Cholesky factorization module. -///! -///! Contains LDLT decomposition methods. -///! -///! This decomposition operates on symmetric positive definite matrices, -///! and is written `A = L D L` where L is lower triangular and D is diagonal. -///! It is closely related to the Cholesky decomposition, but is often more -///! numerically stable and can work on some indefinite matrices. -///! -///! The easiest way to use this API is to create a `LdlNumeric` instance from -///! a matrix, then use the `LdlNumeric::solve` method. -///! -///! It is possible to update a decomposition if the sparsity structure of a -///! matrix does not change. In that case the `LdlNumeric::update` method can -///! be used. -///! -///! When only the sparsity structure of a matrix is known, it is possible -///! to precompute part of the factorization by using the `LdlSymbolic` struct. -///! This struct can the be converted into a `LdlNumeric` once the non-zero -///! values are known, using the `LdlSymbolic::factor` method. -// This method is adapted from the LDL library by Tim Davis: -// -// LDL Copyright (c) 2005 by Timothy A. Davis. All Rights Reserved. -// -// LDL License: -// -// Your use or distribution of LDL or any modified version of -// LDL implies that you agree to this License. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -// USA -// -// Permission is hereby granted to use or copy this program under the -// terms of the GNU LGPL, provided that the Copyright, this License, -// and the Availability of the original version is retained on all copies. -// User documentation of any code that uses this code or any modified -// version of this code must cite the Copyright, this License, the -// Availability note, and "Used by permission." Permission to modify -// the code and to distribute modified code is granted, provided the -// Copyright, this License, and the Availability note are retained, -// and a notice that the code was modified is included. +//! Cholesky factorization module. +//! +//! Contains LDLT decomposition methods. +//! +//! This decomposition operates on symmetric positive definite matrices, +//! and is written `A = L D L` where L is lower triangular and D is diagonal. +//! It is closely related to the Cholesky decomposition, but is often more +//! numerically stable and can work on some indefinite matrices. +//! +//! The easiest way to use this API is to create a `LdlNumeric` instance from +//! a matrix, then use the `LdlNumeric::solve` method. +//! +//! It is possible to update a decomposition if the sparsity structure of a +//! matrix does not change. In that case the `LdlNumeric::update` method can +//! be used. +//! +//! When only the sparsity structure of a matrix is known, it is possible +//! to precompute part of the factorization by using the `LdlSymbolic` struct. +//! This struct can the be converted into a `LdlNumeric` once the non-zero +//! values are known, using the `LdlSymbolic::factor` method. +//! +//! This method is adapted from the LDL library by Tim Davis: +//! +//! LDL Copyright (c) 2005 by Timothy A. Davis. All Rights Reserved. +//! +//! LDL License: +//! +//! Your use or distribution of LDL or any modified version of +//! LDL implies that you agree to this License. +//! +//! This library is free software; you can redistribute it and/or +//! modify it under the terms of the GNU Lesser General Public +//! License as published by the Free Software Foundation; either +//! version 2.1 of the License, or (at your option) any later version. +//! +//! This library is distributed in the hope that it will be useful, +//! but WITHOUT ANY WARRANTY; without even the implied warranty of +//! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +//! Lesser General Public License for more details. +//! +//! You should have received a copy of the GNU Lesser General Public +//! License along with this library; if not, write to the Free Software +//! Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +//! USA +//! +//! Permission is hereby granted to use or copy this program under the +//! terms of the GNU LGPL, provided that the Copyright, this License, +//! and the Availability of the original version is retained on all copies. +//! User documentation of any code that uses this code or any modified +//! version of this code must cite the Copyright, this License, the +//! Availability note, and "Used by permission." Permission to modify +//! the code and to distribute modified code is granted, provided the +//! Copyright, this License, and the Availability note are retained, +//! and a notice that the code was modified is included. use std::ops::Deref; use num_traits::Num; diff --git a/sprs/src/indexing.rs b/sprs/src/indexing.rs index c30cfe96..f707e731 100644 --- a/sprs/src/indexing.rs +++ b/sprs/src/indexing.rs @@ -1,12 +1,12 @@ +//! Abstraction over types of indices +//! +//! Our sparse matrices can use any integer type for its indices among +//! `u16, u32, u64, usize, i16, i32, i64, isize`. +//! +//! By default, sprs matrices will use `usize`, but it can be useful to switch +//! to another index type to reduce the memory usage of sparse matrices, of for +//! compatibility purposes when calling into an existing library through FFI. use std::fmt::Debug; -///! Abstraction over types of indices -///! -///! Our sparse matrices can use any integer type for its indices among -///! `u16, u32, u64, usize, i16, i32, i64, isize`. -///! -///! By default, sprs matrices will use `usize`, but it can be useful to switch -///! to another index type to reduce the memory usage of sparse matrices, of for -///! compatibility purposes when calling into an existing library through FFI. use std::ops::AddAssign; use num_traits::int::PrimInt; diff --git a/sprs/src/sparse/compressed.rs b/sprs/src/sparse/compressed.rs index e9a8d33f..41d4609c 100644 --- a/sprs/src/sparse/compressed.rs +++ b/sprs/src/sparse/compressed.rs @@ -1,5 +1,5 @@ +//! Traits to generalize over compressed sparse matrices storages use crate::indexing::SpIndex; -///! Traits to generalize over compressed sparse matrices storages use crate::sparse::prelude::*; use std::ops::Deref; diff --git a/sprs/src/sparse/csmat.rs b/sprs/src/sparse/csmat.rs index f9e437d8..6b96129c 100644 --- a/sprs/src/sparse/csmat.rs +++ b/sprs/src/sparse/csmat.rs @@ -1,17 +1,17 @@ +//! A sparse matrix in the Compressed Sparse Row/Column format +//! +//! In the CSR format, a matrix is a structure containing three vectors: +//! indptr, indices, and data +//! These vectors satisfy the relation +//! for i in [0, nrows], +//! A(i, indices[indptr[i]..indptr[i+1]]) = data[indptr[i]..indptr[i+1]] +//! In the CSC format, the relation is +//! A(indices[indptr[i]..indptr[i+1]], i) = data[indptr[i]..indptr[i+1]] use ndarray::ArrayView; use num_traits::{Float, Num, Signed, Zero}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use std::cmp; -///! A sparse matrix in the Compressed Sparse Row/Column format -/// -/// In the CSR format, a matrix is a structure containing three vectors: -/// indptr, indices, and data -/// These vectors satisfy the relation -/// for i in [0, nrows], -/// A(i, indices[indptr[i]..indptr[i+1]]) = data[indptr[i]..indptr[i+1]] -/// In the CSC format, the relation is -/// A(indices[indptr[i]..indptr[i+1]], i) = data[indptr[i]..indptr[i+1]] use std::default::Default; use std::iter::{Enumerate, Zip}; use std::mem; diff --git a/sprs/src/sparse/linalg.rs b/sprs/src/sparse/linalg.rs index 55d2a6be..840d0f6c 100644 --- a/sprs/src/sparse/linalg.rs +++ b/sprs/src/sparse/linalg.rs @@ -1,8 +1,9 @@ +//! Sparse linear algebra +//! +//! This module contains solvers for sparse linear systems. Currently +//! there are solver for sparse triangular systems and symmetric systems. + use crate::{DenseVector, DenseVectorMut}; -///! Sparse linear algebra -///! -///! This module contains solvers for sparse linear systems. Currently -///! there are solver for sparse triangular systems and symmetric systems. use num_traits::Num; pub mod etree; diff --git a/sprs/src/sparse/linalg/etree.rs b/sprs/src/sparse/linalg/etree.rs index 468b3c7f..3aeba371 100644 --- a/sprs/src/sparse/linalg/etree.rs +++ b/sprs/src/sparse/linalg/etree.rs @@ -1,5 +1,6 @@ -///! Data structures to work with elimination trees (etree). -///! etrees arise when considering cholesky factorization, QR factorization, ... +//! Data structures to work with elimination trees (etree). +//! etrees arise when considering cholesky factorization, QR factorization, ... + use std::ops::{Deref, DerefMut}; pub type Parent = Option; diff --git a/sprs/src/sparse/prod.rs b/sprs/src/sparse/prod.rs index af81db85..0657221d 100644 --- a/sprs/src/sparse/prod.rs +++ b/sprs/src/sparse/prod.rs @@ -1,7 +1,8 @@ +//! Sparse matrix product + use crate::dense_vector::{DenseVector, DenseVectorMut}; use crate::indexing::SpIndex; use crate::sparse::compressed::SpMatView; -///! Sparse matrix product use crate::sparse::prelude::*; use crate::Ix2; use ndarray::{ArrayView, ArrayViewMut, Axis}; diff --git a/sprs/src/sparse/special_mats.rs b/sprs/src/sparse/special_mats.rs index 440ba1f6..3f25c868 100644 --- a/sprs/src/sparse/special_mats.rs +++ b/sprs/src/sparse/special_mats.rs @@ -1,5 +1,5 @@ +//! Common sparse matrices use ndarray::ArrayView2; -///! Common sparse matrices use smallvec::SmallVec; use crate::indexing::SpIndex; diff --git a/sprs/src/sparse/to_dense.rs b/sprs/src/sparse/to_dense.rs index c8040da7..e3d116b5 100644 --- a/sprs/src/sparse/to_dense.rs +++ b/sprs/src/sparse/to_dense.rs @@ -1,7 +1,8 @@ +//! Utilities for sparse-to-dense conversion + use super::{CsMatViewI, CsVecViewI}; use crate::indexing::SpIndex; use crate::{Ix1, Ix2}; -///! Utilities for sparse-to-dense conversion use ndarray::{ArrayViewMut, Axis}; /// Assign a sparse matrix into a dense matrix diff --git a/sprs/src/sparse/triplet.rs b/sprs/src/sparse/triplet.rs index 2eb83012..944c136a 100644 --- a/sprs/src/sparse/triplet.rs +++ b/sprs/src/sparse/triplet.rs @@ -1,16 +1,16 @@ +//! Triplet format matrix +//! +//! Useful for building a matrix, but not for computations. Therefore this +//! struct is mainly used to initialize a matrix before converting to +//! to a [`CsMat`](CsMatBase). +//! +//! A triplet format matrix is formed of three arrays of equal length, storing +//! the row indices, the column indices, and the values of the non-zero +//! entries. By convention, duplicate locations are summed up when converting +//! into `CsMat`. use crate::indexing::SpIndex; use crate::sparse::prelude::*; -///! Triplet format matrix -///! -///! Useful for building a matrix, but not for computations. Therefore this -///! struct is mainly used to initialize a matrix before converting to -///! to a [`CsMat`](CsMatBase). -///! -///! A triplet format matrix is formed of three arrays of equal length, storing -///! the row indices, the column indices, and the values of the non-zero -///! entries. By convention, duplicate locations are summed up when converting -///! into `CsMat`. use std::ops::{Add, Deref, DerefMut}; use std::slice::Iter;