Skip to content

Commit

Permalink
Bump up nalgebra
Browse files Browse the repository at this point in the history
  • Loading branch information
lan496 committed Feb 12, 2025
1 parent a529810 commit 1aa5299
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 89 deletions.
153 changes: 80 additions & 73 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ license = "MIT OR Apache-2.0"
repository = "https://github.com/spglib/moyo"

[workspace.dependencies]
nalgebra = { version = "0.32", features = ["serde-serialize"] }
nalgebra = { version = "0.33", features = ["serde-serialize"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
approx = "0.5"
Expand Down
4 changes: 4 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ clean:
# Rust
################################################################################

[group('rust')]
test:
cargo test

[group('rust')]
doc:
cargo doc --open
Expand Down
4 changes: 2 additions & 2 deletions moyo/src/math/cycle_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use nalgebra::{DefaultAllocator, Dim, OMatrix};
#[derive(Debug)]
pub struct CycleChecker<N: Dim>
where
DefaultAllocator: Allocator<i32, N, N>,
DefaultAllocator: Allocator<N, N>,
{
visited: HashSet<OMatrix<i32, N, N>>,
}

impl<N: Dim> CycleChecker<N>
where
DefaultAllocator: Allocator<i32, N, N>,
DefaultAllocator: Allocator<N, N>,
{
pub fn new() -> Self {
Self {
Expand Down
6 changes: 3 additions & 3 deletions moyo/src/math/elementary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use nalgebra::{DefaultAllocator, Dim, OMatrix};
/// Return elementary matrix swapping the `col1`th and `col2`th columns
pub fn swapping_column_matrix<D: Dim>(dim: D, col1: usize, col2: usize) -> OMatrix<i32, D, D>
where
DefaultAllocator: Allocator<i32, D, D>,
DefaultAllocator: Allocator<D, D>,
{
let mut trans_mat = OMatrix::zeros_generic(dim, dim);
for i in 0..dim.value() {
Expand All @@ -22,7 +22,7 @@ where
/// Return elementary matrix adding the `k`-multiplied `col1`th column into the `col2`th column
pub fn adding_column_matrix<D: Dim>(dim: D, col1: usize, col2: usize, k: i32) -> OMatrix<i32, D, D>
where
DefaultAllocator: Allocator<i32, D, D>,
DefaultAllocator: Allocator<D, D>,
{
let mut trans_mat = OMatrix::identity_generic(dim, dim);
for i in 0..dim.value() {
Expand All @@ -36,7 +36,7 @@ where
/// Return elementary matrix changing sign of the `col`th column
pub fn changing_column_sign_matrix<D: Dim>(dim: D, col: usize) -> OMatrix<i32, D, D>
where
DefaultAllocator: Allocator<i32, D, D>,
DefaultAllocator: Allocator<D, D>,
{
let mut trans_mat = OMatrix::identity_generic(dim, dim);
trans_mat[(col, col)] = -1;
Expand Down
4 changes: 2 additions & 2 deletions moyo/src/math/hnf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ use super::elementary::{
#[allow(clippy::upper_case_acronyms)]
pub struct HNF<M: Dim, N: Dim>
where
DefaultAllocator: Allocator<i32, M, N> + Allocator<i32, N, N>,
DefaultAllocator: Allocator<M, N> + Allocator<N, N>,
{
pub h: OMatrix<i32, M, N>,
pub r: OMatrix<i32, N, N>,
}

impl<M: Dim, N: Dim> HNF<M, N>
where
DefaultAllocator: Allocator<i32, M, N> + Allocator<i32, N, N>,
DefaultAllocator: Allocator<M, N> + Allocator<N, N>,
{
/// Return column-wise Hermite norm form
pub fn new(basis: &OMatrix<i32, M, N>) -> Self {
Expand Down
7 changes: 3 additions & 4 deletions moyo/src/math/integer_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::snf::SNF;
#[derive(Debug)]
pub struct IntegerLinearSystem<N: Dim>
where
DefaultAllocator: Allocator<i32, N>,
DefaultAllocator: Allocator<N>,
{
/// rank of the integer linear system
#[allow(dead_code)]
Expand All @@ -20,14 +20,13 @@ where

impl<N: Dim> IntegerLinearSystem<N>
where
DefaultAllocator: Allocator<i32, N>,
DefaultAllocator: Allocator<N>,
{
/// Solve a * x = b
/// If no solution, return None
pub fn new<M: DimMin<N>>(a: &OMatrix<i32, M, N>, b: &OVector<i32, M>) -> Option<Self>
where
DefaultAllocator:
Allocator<i32, M, N> + Allocator<i32, M, M> + Allocator<i32, N, N> + Allocator<i32, M>,
DefaultAllocator: Allocator<M, N> + Allocator<M, M> + Allocator<N, N> + Allocator<M>,
{
let (_, n) = a.shape_generic();
let snf = SNF::new(a);
Expand Down
2 changes: 1 addition & 1 deletion moyo/src/math/minkowski.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn minkowski_reduce_greedy<N: Dim + DimName>(
trans_mat: &mut OMatrix<i32, N, N>,
rank: usize,
) where
DefaultAllocator: Allocator<f64, N, N> + Allocator<i32, N, N> + Allocator<f64, N>,
DefaultAllocator: Allocator<N, N> + Allocator<N, N> + Allocator<N>,
{
// Line 1: exit condition
if rank == 1 {
Expand Down
6 changes: 3 additions & 3 deletions moyo/src/math/snf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use nalgebra::{DefaultAllocator, Dim, DimMin, OMatrix};
#[allow(clippy::upper_case_acronyms)]
pub struct SNF<M: DimMin<N>, N: Dim>
where
DefaultAllocator: Allocator<i32, M, N> + Allocator<i32, M, M> + Allocator<i32, N, N>,
DefaultAllocator: Allocator<M, N> + Allocator<M, M> + Allocator<N, N>,
{
pub d: OMatrix<i32, M, N>,
pub l: OMatrix<i32, M, M>,
Expand All @@ -15,11 +15,11 @@ where

impl<M: DimMin<N>, N: Dim> SNF<M, N>
where
DefaultAllocator: Allocator<i32, M, N> + Allocator<i32, M, M> + Allocator<i32, N, N>,
DefaultAllocator: Allocator<M, N> + Allocator<M, M> + Allocator<N, N>,
{
pub fn new(basis: &OMatrix<i32, M, N>) -> SNF<M, N>
where
DefaultAllocator: Allocator<i32, M, N> + Allocator<i32, M, M> + Allocator<i32, N, N>,
DefaultAllocator: Allocator<M, N> + Allocator<M, M> + Allocator<N, N>,
{
let (m, n) = basis.shape_generic();
let mut d = basis.clone();
Expand Down

0 comments on commit 1aa5299

Please sign in to comment.