Remove unneeded dim for VectorStorage

This commit is contained in:
Joshua Coles 2023-03-04 13:02:46 +00:00
parent 1be8e3bd01
commit f0e862616d
3 changed files with 4 additions and 21 deletions

View File

@ -13,7 +13,7 @@ pub struct CStorage(VectorStorage);
#[no_mangle]
pub extern "C" fn storage_new(grid_size: u32) -> &'static mut CStorage {
let mut pntr = Box::new(CStorage(VectorStorage::new(grid_size, 2)));
let mut pntr = Box::new(CStorage(VectorStorage::new(grid_size)));
Box::leak(pntr)
}
@ -30,22 +30,6 @@ pub extern "C" fn storage_deposit(storage: &mut CStorage, i: i32, j: i32, val: u
#[no_mangle]
pub extern "C" fn walk(d: u32, i: i32, j: i32) -> CPosition {
return test::b(d, i, j);
// match d {
// 0 => CPosition(i + 1, j),
// 1 => CPosition(i - 1, j),
// 2 => CPosition(i, j + 1),
// 3 => CPosition(i, j - 1),
// _ => panic!("Ahh"),
// }
// let (dim, sign) = d.div_rem(&2);
// let sign = if sign == 0 { -1 } else { 1 };
// // HACK: Our conventin and the MVA are different, since we are trying to strangle fig this, quick hack.
// let offset = Position::in_direction(1 - dim, sign * -1);
// let next = Position(i, j) + offset;
//
// CPosition(next.0, next.1)
}
mod test {

View File

@ -38,7 +38,7 @@ impl<R: Rng, P: GriddedPosition, S: Storage<P>, W: Walker<P>> DLASystem<R, P, S,
max_particles,
running: true,
space: VectorStorage::new(1600, 2),
space: VectorStorage::new(1600),
walker: LocalRandomWalker,
particles: vec![],
active_particle: None,

View File

@ -8,12 +8,11 @@ pub trait Storage<P: GriddedPosition> {
pub struct VectorStorage {
backing: Vec<bool>,
grid_size: u32,
dim: u32,
}
impl VectorStorage {
pub fn new(grid_size: u32, dim: u32) -> VectorStorage {
VectorStorage { grid_size, dim, backing: vec![false; grid_size.pow(dim) as usize] }
pub fn new(grid_size: u32) -> VectorStorage {
VectorStorage { grid_size, backing: vec![false; grid_size.pow(2) as usize] }
}
pub fn linear_index(&self, position: &Position) -> usize {