Remove unneeded dim for VectorStorage
This commit is contained in:
parent
1be8e3bd01
commit
f0e862616d
18
src/clib.rs
18
src/clib.rs
@ -13,7 +13,7 @@ pub struct CStorage(VectorStorage);
|
|||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn storage_new(grid_size: u32) -> &'static mut CStorage {
|
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)
|
Box::leak(pntr)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,22 +30,6 @@ pub extern "C" fn storage_deposit(storage: &mut CStorage, i: i32, j: i32, val: u
|
|||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn walk(d: u32, i: i32, j: i32) -> CPosition {
|
pub extern "C" fn walk(d: u32, i: i32, j: i32) -> CPosition {
|
||||||
return test::b(d, i, j);
|
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 {
|
mod test {
|
||||||
|
|||||||
@ -38,7 +38,7 @@ impl<R: Rng, P: GriddedPosition, S: Storage<P>, W: Walker<P>> DLASystem<R, P, S,
|
|||||||
max_particles,
|
max_particles,
|
||||||
running: true,
|
running: true,
|
||||||
|
|
||||||
space: VectorStorage::new(1600, 2),
|
space: VectorStorage::new(1600),
|
||||||
walker: LocalRandomWalker,
|
walker: LocalRandomWalker,
|
||||||
particles: vec![],
|
particles: vec![],
|
||||||
active_particle: None,
|
active_particle: None,
|
||||||
|
|||||||
@ -8,12 +8,11 @@ pub trait Storage<P: GriddedPosition> {
|
|||||||
pub struct VectorStorage {
|
pub struct VectorStorage {
|
||||||
backing: Vec<bool>,
|
backing: Vec<bool>,
|
||||||
grid_size: u32,
|
grid_size: u32,
|
||||||
dim: u32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VectorStorage {
|
impl VectorStorage {
|
||||||
pub fn new(grid_size: u32, dim: u32) -> VectorStorage {
|
pub fn new(grid_size: u32) -> VectorStorage {
|
||||||
VectorStorage { grid_size, dim, backing: vec![false; grid_size.pow(dim) as usize] }
|
VectorStorage { grid_size, backing: vec![false; grid_size.pow(2) as usize] }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn linear_index(&self, position: &Position) -> usize {
|
pub fn linear_index(&self, position: &Position) -> usize {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user