Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,40 @@ jobs:

- name: Format check
run: cargo fmt --check

sonarqube:
name: SonarQube
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, llvm-tools-preview

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Generate Clippy report
run: cargo clippy --features alloc --message-format=json &> clippy-report.json

- name: Generate coverage report
run: cargo llvm-cov --features alloc --lcov --output-path lcov.info

- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[![Crates.io](https://img.shields.io/crates/v/rustebra?style=flat-square&color=fc8d62)](https://crates.io/crates/rustebra)
[![docs.rs](https://img.shields.io/docsrs/rustebra?style=flat-square&label=docs.rs)](https://docs.rs/rustebra)
[![CI](https://img.shields.io/github/actions/workflow/status/tec-eli/rustebra/ci.yml?style=flat-square&label=CI)](https://github.com/tec-eli/rustebra/actions/workflows/ci.yml)
[![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=tec-eli_rustebra)](https://sonarcloud.io/summary/new_code?id=tec-eli_rustebra)
[![License](https://img.shields.io/badge/license-Apache_2.0-blue?style=flat-square)](https://opensource.org/licenses/Apache-2.0)
[![no_std](https://img.shields.io/badge/no__std-compatible-success?style=flat-square)](https://docs.rust-embedded.org/book/)
[![MSRV](https://img.shields.io/badge/MSRV-1.85-orange?style=flat-square)](https://blog.rust-lang.org/2025/02/20/Rust-1.85.0.html)
Expand Down
9 changes: 9 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
sonar.projectKey=tec-eli_rustebra
sonar.organization=tec-eli
sonar.projectName=rustebra
sonar.sources=src
sonar.tests=tests

sonar.rust.clippy.enabled=false
sonar.rust.clippy.reportPaths=clippy-report.json
sonar.rust.lcov.reportPaths=lcov.info
42 changes: 35 additions & 7 deletions src/krylov/arnoldi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,21 @@ mod tests {
// Upper Hessenberg: zero strictly below the first subdiagonal.
assert_close(h.entry(2, 0).unwrap(), 0.0, 1e-10);

assert_close(projection_entry(&a, 3, &basis, 0, 0), h.entry(0, 0).unwrap(), 1e-10);
assert_close(projection_entry(&a, 3, &basis, 1, 0), h.entry(1, 0).unwrap(), 1e-10);
assert_close(projection_entry(&a, 3, &basis, 2, 1), h.entry(2, 1).unwrap(), 1e-10);
assert_close(
projection_entry(&a, 3, &basis, 0, 0),
h.entry(0, 0).unwrap(),
1e-10,
);
assert_close(
projection_entry(&a, 3, &basis, 1, 0),
h.entry(1, 0).unwrap(),
1e-10,
);
assert_close(
projection_entry(&a, 3, &basis, 2, 1),
h.entry(2, 1).unwrap(),
1e-10,
);
}

#[test]
Expand Down Expand Up @@ -313,10 +325,26 @@ mod tests {
let inner: f64 = q_0.iter().zip(q_1.iter()).map(|(x, y)| x * y).sum();
assert_close(inner, 0.0, 1e-12);

assert_close(projection_entry(&a, 3, &basis, 0, 0), h.entry(0, 0).unwrap(), 1e-10);
assert_close(projection_entry(&a, 3, &basis, 0, 1), h.entry(0, 1).unwrap(), 1e-10);
assert_close(projection_entry(&a, 3, &basis, 1, 0), h.entry(1, 0).unwrap(), 1e-10);
assert_close(projection_entry(&a, 3, &basis, 1, 1), h.entry(1, 1).unwrap(), 1e-10);
assert_close(
projection_entry(&a, 3, &basis, 0, 0),
h.entry(0, 0).unwrap(),
1e-10,
);
assert_close(
projection_entry(&a, 3, &basis, 0, 1),
h.entry(0, 1).unwrap(),
1e-10,
);
assert_close(
projection_entry(&a, 3, &basis, 1, 0),
h.entry(1, 0).unwrap(),
1e-10,
);
assert_close(
projection_entry(&a, 3, &basis, 1, 1),
h.entry(1, 1).unwrap(),
1e-10,
);
}

#[test]
Expand Down
4 changes: 3 additions & 1 deletion tests/edge_cases/krylov.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
//! dimension mismatches, and the zero vector — cases the property harness deliberately never
//! generates.

use rustebra::krylov::{ConvergenceError, arnoldi, inverse_power_iteration, lanczos, power_iteration};
use rustebra::krylov::{
ConvergenceError, arnoldi, inverse_power_iteration, lanczos, power_iteration,
};
use rustebra::storage::{Basis, StaticStorage};

use crate::common::{
Expand Down
4 changes: 3 additions & 1 deletion tests/numerical_stress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#[allow(dead_code)]
mod common;

use rustebra::krylov::{ConvergenceError, arnoldi, inverse_power_iteration, lanczos, power_iteration};
use rustebra::krylov::{
ConvergenceError, arnoldi, inverse_power_iteration, lanczos, power_iteration,
};
use rustebra::storage::{Basis, StaticStorage};

use common::{
Expand Down
4 changes: 3 additions & 1 deletion tests/property/krylov/arnoldi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use proptest::prelude::*;
use rustebra::krylov::arnoldi;
use rustebra::storage::{Basis, StaticStorage};

use super::common::{ALGORITHM_TOL, ASSERTION_TOL, N, nonsymmetric_with_spectrum, spectrum_with_gap};
use super::common::{
ALGORITHM_TOL, ASSERTION_TOL, N, nonsymmetric_with_spectrum, spectrum_with_gap,
};

/// `Qᵗ * A * Q` entry `(r, c)` from the basis, against the row-major `N x N` matrix `a`.
fn projection_entry(a: &[f64; N * N], basis: &Basis<'_, f64, N>, r: usize, c: usize) -> f64 {
Expand Down
3 changes: 1 addition & 2 deletions tests/property/krylov/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// The shared harness also serves the edge-case and stress targets; the fixed-matrix helpers
// are unused in this one.
mod arnoldi;
#[allow(dead_code)]
mod common;
mod arnoldi;
mod inverse_power_iteration;
mod lanczos;
mod power_iteration;

Loading