diff --git a/ext/crates/algebra/src/algebra/adem_algebra.rs b/ext/crates/algebra/src/algebra/adem_algebra.rs index 1cc6a41cf..0ade6d56e 100644 --- a/ext/crates/algebra/src/algebra/adem_algebra.rs +++ b/ext/crates/algebra/src/algebra/adem_algebra.rs @@ -16,11 +16,8 @@ use nom::{ IResult, }; -use fp::vector::{BaseVector, FpVector, SliceMut}; -use fp::{ - prime::{BinomialIterator, BitflagIterator, ValidPrime}, - vector::BaseVectorMut, -}; +use fp::prime::{BinomialIterator, BitflagIterator, ValidPrime}; +use fp::vector::{FpVector, SliceMut}; use once::OnceVec; use crate::algebra::combinatorics::{self, MAX_XI_TAU}; diff --git a/ext/crates/algebra/src/algebra/algebra_trait.rs b/ext/crates/algebra/src/algebra/algebra_trait.rs index d3d602511..ddc1972db 100644 --- a/ext/crates/algebra/src/algebra/algebra_trait.rs +++ b/ext/crates/algebra/src/algebra/algebra_trait.rs @@ -1,5 +1,5 @@ use fp::prime::ValidPrime; -use fp::vector::{BaseVector, Slice, SliceMut}; +use fp::vector::{Slice, SliceMut}; #[cfg(doc)] use fp::vector::FpVector; diff --git a/ext/crates/algebra/src/algebra/combinatorics.rs b/ext/crates/algebra/src/algebra/combinatorics.rs index bdd907526..20097d6e3 100644 --- a/ext/crates/algebra/src/algebra/combinatorics.rs +++ b/ext/crates/algebra/src/algebra/combinatorics.rs @@ -1,4 +1,4 @@ -use fp::vector::{BaseVector, BaseVectorMut, FpVector}; +use fp::vector::FpVector; use once::OnceVec; use fp::prime::{minus_one_to_the_n, Binomial, ValidPrime}; diff --git a/ext/crates/algebra/src/algebra/field.rs b/ext/crates/algebra/src/algebra/field.rs index 8d8e0efb9..6f31637c0 100644 --- a/ext/crates/algebra/src/algebra/field.rs +++ b/ext/crates/algebra/src/algebra/field.rs @@ -2,7 +2,7 @@ use crate::algebra::{Algebra, Bialgebra}; use fp::prime::ValidPrime; -use fp::vector::{BaseVector, BaseVectorMut, Slice, SliceMut}; +use fp::vector::{Slice, SliceMut}; /// $\mathbb{F}_p$, viewed as an [`Algebra`] over itself. /// diff --git a/ext/crates/algebra/src/algebra/milnor_algebra.rs b/ext/crates/algebra/src/algebra/milnor_algebra.rs index 2d1754d99..90fb01d3c 100644 --- a/ext/crates/algebra/src/algebra/milnor_algebra.rs +++ b/ext/crates/algebra/src/algebra/milnor_algebra.rs @@ -5,7 +5,7 @@ use std::sync::Mutex; use crate::algebra::combinatorics; use crate::algebra::{Algebra, Bialgebra, GeneratedAlgebra}; use fp::prime::{integer_power, Binomial, BitflagIterator, ValidPrime}; -use fp::vector::{BaseVector, BaseVectorMut, FpVector, Slice, SliceMut}; +use fp::vector::{FpVector, Slice, SliceMut}; use once::OnceVec; #[cfg(feature = "json")] diff --git a/ext/crates/algebra/src/algebra/polynomial_algebra.rs b/ext/crates/algebra/src/algebra/polynomial_algebra.rs index 3d50853fa..1627528ba 100644 --- a/ext/crates/algebra/src/algebra/polynomial_algebra.rs +++ b/ext/crates/algebra/src/algebra/polynomial_algebra.rs @@ -3,7 +3,7 @@ use rustc_hash::FxHashMap as HashMap; use std::fmt; use fp::prime::ValidPrime; -use fp::vector::{BaseVector, BaseVectorMut, FpVector, SliceMut}; +use fp::vector::{FpVector, SliceMut}; use once::OnceVec; use crate::algebra::combinatorics::TruncatedPolynomialMonomialBasis; diff --git a/ext/crates/algebra/src/change_of_basis.rs b/ext/crates/algebra/src/change_of_basis.rs index b67282ee1..ed3d59841 100644 --- a/ext/crates/algebra/src/change_of_basis.rs +++ b/ext/crates/algebra/src/change_of_basis.rs @@ -1,7 +1,7 @@ use crate::algebra::adem_algebra::AdemBasisElement; use crate::algebra::milnor_algebra::{MilnorBasisElement, PPart, PPartEntry}; use crate::algebra::{AdemAlgebra, Algebra, MilnorAlgebra}; -use fp::vector::{BaseVector, BaseVectorMut, FpVector}; +use fp::vector::FpVector; // use std::sync::Arc; diff --git a/ext/crates/algebra/src/module/bcp.rs b/ext/crates/algebra/src/module/bcp.rs index 9cb87d91a..b400e32be 100644 --- a/ext/crates/algebra/src/module/bcp.rs +++ b/ext/crates/algebra/src/module/bcp.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use fp::prime::ValidPrime; -use fp::vector::{BaseVectorMut, FpVector}; +use fp::vector::FpVector; use once::OnceVec; use crate::algebra::combinatorics::TruncatedPolynomialMonomialBasis; diff --git a/ext/crates/algebra/src/module/block_structure.rs b/ext/crates/algebra/src/module/block_structure.rs index 44eda2675..969108f26 100644 --- a/ext/crates/algebra/src/module/block_structure.rs +++ b/ext/crates/algebra/src/module/block_structure.rs @@ -6,7 +6,7 @@ // we have to pull out each block and multiply each block separately by the steenrod operation. use bivec::BiVec; -use fp::vector::{BaseVector, BaseVectorMut, Slice, SliceMut}; +use fp::vector::{Slice, SliceMut}; #[derive(Debug)] pub struct GeneratorBasisEltPair { diff --git a/ext/crates/algebra/src/module/bounded_module.rs b/ext/crates/algebra/src/module/bounded_module.rs index 9a4004052..ceb325a03 100644 --- a/ext/crates/algebra/src/module/bounded_module.rs +++ b/ext/crates/algebra/src/module/bounded_module.rs @@ -1,5 +1,4 @@ use bivec::BiVec; -use fp::vector::BaseVectorMut; use fp::vector::FpVector; use crate::module::FDModule; diff --git a/ext/crates/algebra/src/module/dickson2.rs b/ext/crates/algebra/src/module/dickson2.rs index 75f66f63e..26dbd2a26 100644 --- a/ext/crates/algebra/src/module/dickson2.rs +++ b/ext/crates/algebra/src/module/dickson2.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use fp::prime::ValidPrime; -use fp::vector::{BaseVectorMut, FpVector}; +use fp::vector::FpVector; use once::OnceVec; use crate::algebra::{ diff --git a/ext/crates/algebra/src/module/finite_dimensional_module.rs b/ext/crates/algebra/src/module/finite_dimensional_module.rs index f7cb45780..65171c6c6 100644 --- a/ext/crates/algebra/src/module/finite_dimensional_module.rs +++ b/ext/crates/algebra/src/module/finite_dimensional_module.rs @@ -1,7 +1,7 @@ use crate::algebra::Algebra; use crate::module::{BoundedModule, Module, ZeroModule}; use bivec::BiVec; -use fp::vector::{BaseVector, BaseVectorMut, FpVector, SliceMut}; +use fp::vector::{FpVector, SliceMut}; use std::sync::Arc; #[cfg(feature = "json")] diff --git a/ext/crates/algebra/src/module/finitely_presented_module.rs b/ext/crates/algebra/src/module/finitely_presented_module.rs index 64530e2e4..1882c7f7d 100644 --- a/ext/crates/algebra/src/module/finitely_presented_module.rs +++ b/ext/crates/algebra/src/module/finitely_presented_module.rs @@ -4,7 +4,7 @@ use crate::algebra::Algebra; use crate::module::homomorphism::{FreeModuleHomomorphism, ModuleHomomorphism}; use crate::module::{FreeModule, Module, ZeroModule}; use fp::matrix::Matrix; -use fp::vector::{BaseVector, BaseVectorMut, FpVector, SliceMut}; +use fp::vector::{FpVector, SliceMut}; use once::OnceBiVec; #[cfg(feature = "json")] diff --git a/ext/crates/algebra/src/module/free_module.rs b/ext/crates/algebra/src/module/free_module.rs index c5cd804c4..3d0bbcd4d 100644 --- a/ext/crates/algebra/src/module/free_module.rs +++ b/ext/crates/algebra/src/module/free_module.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use crate::algebra::Algebra; use crate::module::Module; -use fp::vector::{BaseVector, BaseVectorMut, Slice, SliceMut}; +use fp::vector::{Slice, SliceMut}; use once::{OnceBiVec, OnceVec}; #[cfg(feature = "json")] diff --git a/ext/crates/algebra/src/module/free_unstable_module.rs b/ext/crates/algebra/src/module/free_unstable_module.rs index 7f603aa60..fb046ce99 100644 --- a/ext/crates/algebra/src/module/free_unstable_module.rs +++ b/ext/crates/algebra/src/module/free_unstable_module.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use crate::algebra::{AdemAlgebra, AdemAlgebraT}; use crate::module::Module; use crate::module::OperationGeneratorPair; -use fp::vector::{BaseVector, BaseVectorMut, SliceMut}; +use fp::vector::SliceMut; use once::{OnceBiVec, OnceVec}; #[cfg(feature = "json")] diff --git a/ext/crates/algebra/src/module/hom_module.rs b/ext/crates/algebra/src/module/hom_module.rs index 1f82aaa26..2f28c1b2a 100644 --- a/ext/crates/algebra/src/module/hom_module.rs +++ b/ext/crates/algebra/src/module/hom_module.rs @@ -6,7 +6,7 @@ use crate::algebra::{Algebra, Field}; use crate::module::block_structure::BlockStructure; use crate::module::homomorphism::FreeModuleHomomorphism; use crate::module::{BoundedModule, FreeModule, Module}; -use fp::vector::{BaseVector, BaseVectorMut, Slice, SliceMut}; +use fp::vector::{Slice, SliceMut}; use once::OnceBiVec; pub struct HomModule { diff --git a/ext/crates/algebra/src/module/homomorphism/bounded_module_homomorphism.rs b/ext/crates/algebra/src/module/homomorphism/bounded_module_homomorphism.rs index 2977ca4c9..e7b234e31 100644 --- a/ext/crates/algebra/src/module/homomorphism/bounded_module_homomorphism.rs +++ b/ext/crates/algebra/src/module/homomorphism/bounded_module_homomorphism.rs @@ -5,7 +5,7 @@ use crate::module::homomorphism::{IdentityHomomorphism, ModuleHomomorphism, Zero use crate::module::{BoundedModule, Module}; use bivec::BiVec; use fp::matrix::{Matrix, QuasiInverse, Subspace}; -use fp::vector::{BaseVector, BaseVectorMut, SliceMut}; +use fp::vector::SliceMut; use once::OnceBiVec; pub struct BoundedModuleHomomorphism> { diff --git a/ext/crates/algebra/src/module/homomorphism/composition_homomorphism.rs b/ext/crates/algebra/src/module/homomorphism/composition_homomorphism.rs index c087c8148..030b5fc75 100644 --- a/ext/crates/algebra/src/module/homomorphism/composition_homomorphism.rs +++ b/ext/crates/algebra/src/module/homomorphism/composition_homomorphism.rs @@ -1,5 +1,3 @@ -use fp::vector::BaseVector; - use super::{FreeModuleHomomorphism, ModuleHomomorphism}; use crate::module::{FreeModule, Module}; use std::sync::Arc; diff --git a/ext/crates/algebra/src/module/homomorphism/fp_module_homomorphism.rs b/ext/crates/algebra/src/module/homomorphism/fp_module_homomorphism.rs index bbc142fb5..d65171780 100644 --- a/ext/crates/algebra/src/module/homomorphism/fp_module_homomorphism.rs +++ b/ext/crates/algebra/src/module/homomorphism/fp_module_homomorphism.rs @@ -6,7 +6,7 @@ use crate::module::homomorphism::{ }; use crate::module::{FPModule, FreeModule, Module}; use fp::matrix::Matrix; -use fp::vector::{BaseVectorMut, SliceMut}; +use fp::vector::SliceMut; pub struct FPModuleHomomorphism> { source: Arc, diff --git a/ext/crates/algebra/src/module/homomorphism/free_module_homomorphism.rs b/ext/crates/algebra/src/module/homomorphism/free_module_homomorphism.rs index 04226122e..110b14b18 100644 --- a/ext/crates/algebra/src/module/homomorphism/free_module_homomorphism.rs +++ b/ext/crates/algebra/src/module/homomorphism/free_module_homomorphism.rs @@ -5,7 +5,7 @@ use crate::module::free_module::OperationGeneratorPair; use crate::module::homomorphism::{CompositionHomomorphism, ModuleHomomorphism}; use crate::module::{FreeModule, Module}; use fp::matrix::{MatrixSliceMut, QuasiInverse, Subspace}; -use fp::vector::{BaseVector, BaseVectorMut, FpVector, Slice, SliceMut}; +use fp::vector::{FpVector, Slice, SliceMut}; use once::OnceBiVec; pub struct FreeModuleHomomorphism { diff --git a/ext/crates/algebra/src/module/homomorphism/hom_pullback.rs b/ext/crates/algebra/src/module/homomorphism/hom_pullback.rs index 718395adc..d53ed00fc 100644 --- a/ext/crates/algebra/src/module/homomorphism/hom_pullback.rs +++ b/ext/crates/algebra/src/module/homomorphism/hom_pullback.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use crate::module::block_structure::BlockStart; use fp::matrix::{QuasiInverse, Subspace}; -use fp::vector::{BaseVector, BaseVectorMut, SliceMut}; +use fp::vector::SliceMut; use once::OnceBiVec; // use crate::algebra::SteenrodAlgebra; // use crate::field::Field; diff --git a/ext/crates/algebra/src/module/homomorphism/mod.rs b/ext/crates/algebra/src/module/homomorphism/mod.rs index 8e205e155..f0c1511b5 100644 --- a/ext/crates/algebra/src/module/homomorphism/mod.rs +++ b/ext/crates/algebra/src/module/homomorphism/mod.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use crate::module::Module; use fp::matrix::{AugmentedMatrix, MatrixSliceMut, QuasiInverse, Subspace}; use fp::prime::ValidPrime; -use fp::vector::{BaseVector, Slice, SliceMut}; +use fp::vector::{Slice, SliceMut}; mod bounded_module_homomorphism; mod composition_homomorphism; diff --git a/ext/crates/algebra/src/module/homomorphism/quotient_homomorphism.rs b/ext/crates/algebra/src/module/homomorphism/quotient_homomorphism.rs index 80de151e1..065c2ee00 100644 --- a/ext/crates/algebra/src/module/homomorphism/quotient_homomorphism.rs +++ b/ext/crates/algebra/src/module/homomorphism/quotient_homomorphism.rs @@ -1,5 +1,5 @@ use crate::module::{Module, QuotientModule}; -use fp::vector::{BaseVector, BaseVectorMut, FpVector, SliceMut}; +use fp::vector::{FpVector, SliceMut}; use std::sync::Arc; use crate::module::homomorphism::ModuleHomomorphism; diff --git a/ext/crates/algebra/src/module/kfpn.rs b/ext/crates/algebra/src/module/kfpn.rs index 110e2f39b..c77b5619d 100644 --- a/ext/crates/algebra/src/module/kfpn.rs +++ b/ext/crates/algebra/src/module/kfpn.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use fp::prime::ValidPrime; -use fp::vector::{BaseVector, BaseVectorMut, FpVector, SliceMut}; +use fp::vector::{FpVector, SliceMut}; use once::OnceVec; use crate::algebra::{ diff --git a/ext/crates/algebra/src/module/module_trait.rs b/ext/crates/algebra/src/module/module_trait.rs index cff26720f..7059c5319 100644 --- a/ext/crates/algebra/src/module/module_trait.rs +++ b/ext/crates/algebra/src/module/module_trait.rs @@ -2,7 +2,7 @@ use itertools::Itertools; use std::sync::Arc; use fp::prime::ValidPrime; -use fp::vector::{BaseVector, BaseVectorMut, FpVector, Slice, SliceMut}; +use fp::vector::{FpVector, Slice, SliceMut}; use crate::algebra::Algebra; use {crate::module::BoundedModule, crate::module::FDModule, crate::module::TruncatedModule}; diff --git a/ext/crates/algebra/src/module/polynomial_algebra_module.rs b/ext/crates/algebra/src/module/polynomial_algebra_module.rs index 03e87750d..263c69383 100644 --- a/ext/crates/algebra/src/module/polynomial_algebra_module.rs +++ b/ext/crates/algebra/src/module/polynomial_algebra_module.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use fp::vector::{BaseVector, BaseVectorMut, FpVector, Slice, SliceMut}; +use fp::vector::{FpVector, Slice, SliceMut}; use once::OnceVec; use crate::algebra::{AdemAlgebraT, Algebra}; @@ -335,7 +335,7 @@ pub trait PolynomialAlgebraModule: PolynomialAlgebra { result_degree, i32::max_value(), )); - result.add(&*reducer_a, 1); + result.add(reducer_a, 1); } result } @@ -388,7 +388,7 @@ pub trait PolynomialAlgebraModule: PolynomialAlgebra { result_degree, i32::max_value(), )); - result.add(&*reducer_a, 1); + result.add(reducer_a, 1); } result } diff --git a/ext/crates/algebra/src/module/quotient_module.rs b/ext/crates/algebra/src/module/quotient_module.rs index 4efa5d0d6..64aeaf8c9 100644 --- a/ext/crates/algebra/src/module/quotient_module.rs +++ b/ext/crates/algebra/src/module/quotient_module.rs @@ -1,6 +1,6 @@ use crate::module::{BoundedModule, Module}; use fp::matrix::Subspace; -use fp::vector::{BaseVector, BaseVectorMut, FpVector, Slice, SliceMut}; +use fp::vector::{FpVector, Slice, SliceMut}; use once::OnceBiVec; use std::sync::Arc; diff --git a/ext/crates/algebra/src/module/rpn.rs b/ext/crates/algebra/src/module/rpn.rs index 162226ad5..83fee268e 100644 --- a/ext/crates/algebra/src/module/rpn.rs +++ b/ext/crates/algebra/src/module/rpn.rs @@ -4,11 +4,8 @@ use crate::algebra::{ AdemAlgebra, MilnorAlgebra, SteenrodAlgebraBorrow, SteenrodAlgebraT, }; use crate::module::{BoundedModule, Module, ZeroModule}; +use fp::prime::{Binomial, ValidPrime}; use fp::vector::SliceMut; -use fp::{ - prime::{Binomial, ValidPrime}, - vector::BaseVectorMut, -}; use std::sync::Arc; diff --git a/ext/crates/algebra/src/module/sum_module.rs b/ext/crates/algebra/src/module/sum_module.rs index f75d0b9bf..88a39108f 100644 --- a/ext/crates/algebra/src/module/sum_module.rs +++ b/ext/crates/algebra/src/module/sum_module.rs @@ -3,7 +3,7 @@ use once::OnceBiVec; use crate::module::block_structure::{BlockStart, BlockStructure, GeneratorBasisEltPair}; use crate::module::{BoundedModule, Module, ZeroModule}; -use fp::vector::{BaseVectorMut, SliceMut}; +use fp::vector::SliceMut; use std::sync::Arc; diff --git a/ext/crates/algebra/src/module/tensor_module.rs b/ext/crates/algebra/src/module/tensor_module.rs index fbbcc68f3..d68a7c45a 100644 --- a/ext/crates/algebra/src/module/tensor_module.rs +++ b/ext/crates/algebra/src/module/tensor_module.rs @@ -5,7 +5,7 @@ use crate::algebra::{Algebra, Bialgebra}; use crate::module::block_structure::BlockStructure; use crate::module::{BoundedModule, Module, ZeroModule}; use fp::prime::minus_one_to_the_n; -use fp::vector::{BaseVector, BaseVectorMut, FpVector, Slice, SliceMut}; +use fp::vector::{FpVector, Slice, SliceMut}; use std::sync::Arc; diff --git a/ext/crates/algebra/src/steenrod_evaluator.rs b/ext/crates/algebra/src/steenrod_evaluator.rs index 79dc5f49a..9512a182a 100644 --- a/ext/crates/algebra/src/steenrod_evaluator.rs +++ b/ext/crates/algebra/src/steenrod_evaluator.rs @@ -4,7 +4,7 @@ use crate::change_of_basis; use crate::module::Module; use crate::steenrod_parser::BocksteinOrSq; use crate::steenrod_parser::*; -use fp::vector::{BaseVector, BaseVectorMut, FpVector}; +use fp::vector::FpVector; use rustc_hash::FxHashMap as HashMap; // Outputs in the Adem basis. diff --git a/ext/crates/fp/src/vector/generic.rs b/ext/crates/fp/src/vector/generic.rs index f1362509a..f58107102 100644 --- a/ext/crates/fp/src/vector/generic.rs +++ b/ext/crates/fp/src/vector/generic.rs @@ -45,14 +45,6 @@ impl FpVectorP

{ } } - pub fn from_raw_parts(len: usize, limbs: Vec) -> Self { - debug_assert_eq!(limbs.len(), limb::number::

(len)); - Self { - len: LimbLength::from_logical(len), - limbs, - } - } - pub fn new_with_capacity_(len: usize, capacity: usize) -> Self { let length = LimbLength::

::from_logical(len); let mut limbs = Vec::with_capacity(limb::number::

(capacity)); diff --git a/ext/crates/fp/src/vector/mod.rs b/ext/crates/fp/src/vector/mod.rs index fc276e5f6..1fcce2995 100644 --- a/ext/crates/fp/src/vector/mod.rs +++ b/ext/crates/fp/src/vector/mod.rs @@ -198,7 +198,7 @@ mod test { (fn $name:ident($p:ident: ValidPrime) $body:tt $($rest:tt)*) => { #[rstest] #[trace] - fn $name(#[values(2, 3, 5, 7)] p: u32) { + fn $name(#[values(2)] p: u32) { let $p = ValidPrime::new(p); $body @@ -208,7 +208,7 @@ mod test { (fn $name:ident($p:ident: ValidPrime, $dim:ident: usize) $body:tt $($rest:tt)*) => { #[rstest] #[trace] - fn $name(#[values(2, 3, 5, 7)] p: u32, #[values(10, 20, 70, 100, 1000)] $dim: usize) { + fn $name(#[values(2)] p: u32, #[values(10, 20, 70, 100, 1000)] $dim: usize) { let $p = ValidPrime::new(p); $body @@ -218,7 +218,7 @@ mod test { (fn $name:ident($p:ident: ValidPrime, $dim:ident: usize, $slice_start:ident: usize, $slice_end:ident: usize) $body:tt $($rest:tt)*) => { #[rstest] #[trace] - fn $name(#[values(2, 3, 5, 7)] p: u32, #[values(10, 20, 70, 100, 1000)] $dim: usize) { + fn $name(#[values(2)] p: u32, #[values(10, 20, 70, 100, 1000)] $dim: usize) { let $p = ValidPrime::new(p); let $slice_start = match $dim { @@ -435,34 +435,34 @@ mod test { v.assert_list_eq(&v_arr); } - fn test_add_shift_right(p: ValidPrime, dim: usize, slice_start: usize, slice_end: usize) { + fn test_add_shift_left(p: ValidPrime, dim: usize, slice_start: usize, slice_end: usize) { let mut v_arr = random_vector(p, dim); let w_arr = random_vector(p, dim); let mut v = FpVector::from_slice(p, &v_arr); let w = FpVector::from_slice(p, &w_arr); - v.slice_mut(slice_start + 2, slice_end + 2) + v.slice_mut(slice_start - 2, slice_end - 2) .add(w.slice(slice_start, slice_end), 1); - - println!("v : {}", v); - for i in slice_start + 2..slice_end + 2 { - v_arr[i] = (v_arr[i] + w_arr[i - 2]) % *p; + for i in slice_start - 2..slice_end - 2 { + v_arr[i] = (v_arr[i] + w_arr[i + 2]) % *p; } v.assert_list_eq(&v_arr); } - fn test_add_shift_left(p: ValidPrime, dim: usize, slice_start: usize, slice_end: usize) { + fn test_add_shift_right(p: ValidPrime, dim: usize, slice_start: usize, slice_end: usize) { let mut v_arr = random_vector(p, dim); let w_arr = random_vector(p, dim); let mut v = FpVector::from_slice(p, &v_arr); let w = FpVector::from_slice(p, &w_arr); - v.slice_mut(slice_start - 2, slice_end - 2) + v.slice_mut(slice_start + 2, slice_end + 2) .add(w.slice(slice_start, slice_end), 1); - for i in slice_start - 2..slice_end - 2 { - v_arr[i] = (v_arr[i] + w_arr[i + 2]) % *p; + + println!("v : {}", v); + for i in slice_start + 2..slice_end + 2 { + v_arr[i] = (v_arr[i] + w_arr[i - 2]) % *p; } v.assert_list_eq(&v_arr); } @@ -1078,10 +1078,10 @@ mod test { ]; let mut diffs = Vec::new(); for &(in1_limb1, in1_limb2, in2_limb1, in2_limb2, res1, res2) in tests.iter() { - in1.limbs_mut()[1] = in1_limb1; - in1.limbs_mut()[0] = in1_limb2; - in2.limbs_mut()[1] = in2_limb1; - in2.limbs_mut()[0] = in2_limb2; + in1._limbs_mut()[1] = in1_limb1; + in1._limbs_mut()[0] = in1_limb2; + in2._limbs_mut()[1] = in2_limb1; + in2._limbs_mut()[0] = in2_limb2; let test_res1 = in1.sign_rule(&in2); let test_res2 = in2.sign_rule(&in1); let res = (res1, res2); diff --git a/ext/crates/fp/src/vector/specialized.rs b/ext/crates/fp/src/vector/specialized.rs index ffa9259d5..d7aba05bc 100644 --- a/ext/crates/fp/src/vector/specialized.rs +++ b/ext/crates/fp/src/vector/specialized.rs @@ -1,7 +1,4 @@ -use std::{ - io::{self, Read, Write}, - mem::size_of, -}; +use std::io; use itertools::Itertools; use saveload::{Load, Save}; @@ -306,50 +303,9 @@ impl FpVector { match_p!(p, FpVectorP::from(&slice)) } - pub fn num_limbs(p: ValidPrime, len: usize) -> usize { - let entries_per_limb = limb::entries_per_limb(p); - (len + entries_per_limb - 1) / entries_per_limb - } - pub fn padded_len(p: ValidPrime, len: usize) -> usize { - Self::num_limbs(p, len) * limb::entries_per_limb(p) - } - - pub fn from_bytes(p: ValidPrime, len: usize, data: &mut impl Read) -> std::io::Result { - let num_limbs = Self::num_limbs(p, len); - - let mut limbs: Vec; - cfg_if::cfg_if! { - if #[cfg(target_endian = "little")] { - limbs = vec![0; num_limbs]; - let num_bytes = num_limbs * size_of::(); - unsafe { - let buf: &mut [u8] = std::slice::from_raw_parts_mut(limbs.as_mut_ptr() as *mut u8, num_bytes); - data.read_exact(buf).unwrap(); - } - } else { - limbs = Vec::with_capacity(num_limbs); - - for _ in 0..num_limbs { - let mut bytes: [u8; size_of::()] = [0; size_of::()]; - data.read_exact(&mut bytes)?; - limbs.push(Limb::from_le_bytes(bytes)); - } - } - }; - Ok(match_p!(p, FpVectorP::from_raw_parts(len, limbs))) - } - - pub fn to_bytes(&self, buffer: &mut impl Write) -> std::io::Result<()> { - let num_limbs = Self::num_limbs(self.prime(), self.len()); - // self.limbs is allowed to have more limbs than necessary, but we only save the - // necessary ones. - - for limb in &self.limbs()[0..num_limbs] { - let bytes = limb.to_le_bytes(); - buffer.write_all(&bytes)?; - } - Ok(()) + let entries_per_limb = limb::entries_per_limb(p); + ((len + entries_per_limb - 1) / entries_per_limb) * entries_per_limb } pub(crate) fn limbs(&self) -> &[Limb] { diff --git a/ext/crates/sseq/src/differential.rs b/ext/crates/sseq/src/differential.rs index f52d9a125..6f01cf674 100644 --- a/ext/crates/sseq/src/differential.rs +++ b/ext/crates/sseq/src/differential.rs @@ -1,7 +1,7 @@ use fp::{ matrix::{Matrix, Subspace}, prime::ValidPrime, - vector::{BaseVector, BaseVectorMut, FpVector, Slice, SliceMut}, + vector::{FpVector, Slice, SliceMut}, }; pub struct Differential { diff --git a/ext/crates/sseq/src/sseq.rs b/ext/crates/sseq/src/sseq.rs index 319a10dfb..64bd669d8 100644 --- a/ext/crates/sseq/src/sseq.rs +++ b/ext/crates/sseq/src/sseq.rs @@ -4,7 +4,7 @@ use bivec::BiVec; use fp::{ matrix::{Matrix, Subquotient, Subspace}, prime::ValidPrime, - vector::{BaseVector, BaseVectorMut, FpVector, Slice}, + vector::{FpVector, Slice}, }; use std::{marker::PhantomData, sync::Arc}; diff --git a/ext/examples/bruner.rs b/ext/examples/bruner.rs index 7b67e818d..b1cad87fd 100644 --- a/ext/examples/bruner.rs +++ b/ext/examples/bruner.rs @@ -98,11 +98,7 @@ use ext::{ resolution_homomorphism::ResolutionHomomorphism, utils::construct, }; -use fp::{ - matrix::Matrix, - prime::ValidPrime, - vector::{BaseVectorMut, FpVector}, -}; +use fp::{matrix::Matrix, prime::ValidPrime, vector::FpVector}; use std::{ fs::File, io::{BufRead, BufReader}, diff --git a/ext/examples/chart.rs b/ext/examples/chart.rs index c7293f084..eb2a5e7da 100644 --- a/ext/examples/chart.rs +++ b/ext/examples/chart.rs @@ -2,7 +2,6 @@ use algebra::module::{Module, OperationGeneratorPair}; use chart::{Backend, SvgBackend}; use ext::chain_complex::ChainComplex; use ext::utils::query_module; -use fp::vector::BaseVector; fn main() -> anyhow::Result<()> { let f = std::io::stdout(); diff --git a/ext/examples/define_module.rs b/ext/examples/define_module.rs index 63b2a47a1..b96467be5 100644 --- a/ext/examples/define_module.rs +++ b/ext/examples/define_module.rs @@ -10,7 +10,7 @@ use algebra::steenrod_evaluator::evaluate_module; use algebra::{AdemAlgebra, Algebra, GeneratedAlgebra, MilnorAlgebra, SteenrodAlgebra}; use bivec::BiVec; use fp::prime::ValidPrime; -use fp::vector::{BaseVector, BaseVectorMut, FpVector}; +use fp::vector::FpVector; pub fn get_gens() -> anyhow::Result>> { // Query for generators diff --git a/ext/examples/lift_hom.rs b/ext/examples/lift_hom.rs index a8d50d13b..10e7129a4 100644 --- a/ext/examples/lift_hom.rs +++ b/ext/examples/lift_hom.rs @@ -44,7 +44,6 @@ use ext::chain_complex::ChainComplex; use ext::resolution_homomorphism::ResolutionHomomorphism; use ext::utils; use fp::matrix::Matrix; -use fp::vector::{BaseVector, BaseVectorMut}; use std::sync::Arc; diff --git a/ext/examples/massey.rs b/ext/examples/massey.rs index d120aed01..aaa1d2b89 100644 --- a/ext/examples/massey.rs +++ b/ext/examples/massey.rs @@ -6,7 +6,6 @@ use ext::chain_complex::{ChainComplex, ChainHomotopy, FiniteChainComplex}; use ext::resolution::Resolution; use ext::resolution_homomorphism::ResolutionHomomorphism; use fp::matrix::{AugmentedMatrix, Matrix}; -use fp::vector::{BaseVector, BaseVectorMut}; use std::sync::Arc; fn parse_vec(s: &str) -> Result, core::num::ParseIntError> { diff --git a/ext/examples/save_bruner.rs b/ext/examples/save_bruner.rs index bfec7c381..334137bc2 100644 --- a/ext/examples/save_bruner.rs +++ b/ext/examples/save_bruner.rs @@ -4,7 +4,6 @@ use algebra::module::Module; use algebra::{Algebra, AlgebraType, MilnorAlgebraT}; use ext::{chain_complex::ChainComplex, utils::query_module}; -use fp::vector::BaseVector; use itertools::Itertools; use std::fmt::Write as _; use std::fs::File; diff --git a/ext/examples/steenrod.rs b/ext/examples/steenrod.rs index f064b08a1..f25ea0d21 100644 --- a/ext/examples/steenrod.rs +++ b/ext/examples/steenrod.rs @@ -8,7 +8,7 @@ use ext::utils; use ext::yoneda::yoneda_representative_element; use fp::matrix::Matrix; use fp::prime::ValidPrime; -use fp::vector::{BaseVector, BaseVectorMut, FpVector}; +use fp::vector::FpVector; use std::io::{stderr, stdout, Write}; use std::sync::Arc; diff --git a/ext/examples/yoneda.rs b/ext/examples/yoneda.rs index d50608709..f897daeee 100644 --- a/ext/examples/yoneda.rs +++ b/ext/examples/yoneda.rs @@ -4,7 +4,6 @@ use ext::chain_complex::ChainComplex; use ext::resolution_homomorphism::ResolutionHomomorphism; use ext::utils::construct; use ext::yoneda::yoneda_representative_element; -use fp::vector::BaseVector; use serde_json::value::Value; use std::path::PathBuf; diff --git a/ext/src/chain_complex/chain_homotopy.rs b/ext/src/chain_complex/chain_homotopy.rs index 4cee4e227..1cb76aed6 100644 --- a/ext/src/chain_complex/chain_homotopy.rs +++ b/ext/src/chain_complex/chain_homotopy.rs @@ -2,7 +2,7 @@ use crate::chain_complex::{ChainComplex, FreeChainComplex}; use algebra::module::homomorphism::{FreeModuleHomomorphism, ModuleHomomorphism}; use algebra::module::Module; use fp::prime::ValidPrime; -use fp::vector::{BaseVector, BaseVectorMut, FpVector}; +use fp::vector::FpVector; use once::OnceVec; use std::sync::Mutex; diff --git a/ext/src/chain_complex/mod.rs b/ext/src/chain_complex/mod.rs index 753870862..bf13d0d17 100644 --- a/ext/src/chain_complex/mod.rs +++ b/ext/src/chain_complex/mod.rs @@ -8,7 +8,7 @@ use algebra::module::{FreeModule, Module}; use algebra::Algebra; use fp::matrix::Subquotient; use fp::prime::ValidPrime; -use fp::vector::{BaseVectorMut, FpVector, Slice, SliceMut}; +use fp::vector::{FpVector, Slice, SliceMut}; use std::sync::Arc; // pub use hom_complex::HomComplex; diff --git a/ext/src/chain_complex/tensor_product_chain_complex.rs b/ext/src/chain_complex/tensor_product_chain_complex.rs index f3ea3d4c7..d24031dfa 100644 --- a/ext/src/chain_complex/tensor_product_chain_complex.rs +++ b/ext/src/chain_complex/tensor_product_chain_complex.rs @@ -6,7 +6,7 @@ use algebra::module::homomorphism::{ use algebra::module::{FiniteModule, Module, SumModule, TensorModule, ZeroModule}; use algebra::{Algebra, Bialgebra, SteenrodAlgebra}; use fp::matrix::Matrix; -use fp::vector::{BaseVector, BaseVectorMut, FpVector, Slice, SliceMut}; +use fp::vector::{FpVector, Slice, SliceMut}; use std::sync::Arc; use bivec::BiVec; diff --git a/ext/src/resolution.rs b/ext/src/resolution.rs index 8913140a5..0fa922b19 100644 --- a/ext/src/resolution.rs +++ b/ext/src/resolution.rs @@ -7,7 +7,7 @@ use algebra::module::{FreeModule, Module}; use algebra::Algebra; use fp::matrix::{AugmentedMatrix, QuasiInverse, Subspace}; use fp::prime::ValidPrime; -use fp::vector::{BaseVector, BaseVectorMut, FpVector, Slice, SliceMut}; +use fp::vector::{FpVector, Slice, SliceMut}; use once::OnceVec; use std::path::{Path, PathBuf}; diff --git a/ext/src/resolution_homomorphism.rs b/ext/src/resolution_homomorphism.rs index b966ea14d..10e209ef8 100644 --- a/ext/src/resolution_homomorphism.rs +++ b/ext/src/resolution_homomorphism.rs @@ -10,7 +10,7 @@ use algebra::module::homomorphism::{FreeModuleHomomorphism, ModuleHomomorphism}; use algebra::module::Module; use algebra::SteenrodAlgebra; use fp::matrix::Matrix; -use fp::vector::{BaseVector, BaseVectorMut, FpVector, SliceMut}; +use fp::vector::{FpVector, SliceMut}; use once::OnceBiVec; use anyhow::Context; diff --git a/ext/src/utils.rs b/ext/src/utils.rs index fd0442077..97366939a 100644 --- a/ext/src/utils.rs +++ b/ext/src/utils.rs @@ -5,8 +5,6 @@ use algebra::module::{FiniteModule, Module}; use algebra::{AlgebraType, SteenrodAlgebra}; use anyhow::{anyhow, Context}; -use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; -use fp::vector::{BaseVector, BaseVectorMut}; use serde_json::Value; use std::convert::{TryFrom, TryInto}; diff --git a/ext/src/yoneda.rs b/ext/src/yoneda.rs index 72179a564..f78779b57 100644 --- a/ext/src/yoneda.rs +++ b/ext/src/yoneda.rs @@ -13,7 +13,7 @@ use algebra::module::{BoundedModule, FDModule, FiniteModule, FreeModule, Module} use algebra::module::{QuotientModule as QM, TruncatedModule as TM}; use algebra::{AdemAlgebra, Algebra, GeneratedAlgebra, SteenrodAlgebra}; use fp::matrix::{Matrix, Subspace}; -use fp::vector::{BaseVector, BaseVectorMut, FpVector}; +use fp::vector::FpVector; use bivec::BiVec; diff --git a/ext/tests/extend_identity.rs b/ext/tests/extend_identity.rs index aaf4a7bed..5cbdc5d56 100644 --- a/ext/tests/extend_identity.rs +++ b/ext/tests/extend_identity.rs @@ -3,7 +3,7 @@ use algebra::module::Module; use ext::chain_complex::{AugmentedChainComplex, ChainComplex}; use ext::resolution_homomorphism::ResolutionHomomorphism; use ext::utils::{construct, Config}; -use fp::vector::{BaseVectorMut, FpVector}; +use fp::vector::FpVector; use serde_json::json; use std::convert::TryInto; use std::sync::Arc;