Skip to content

Commit

Permalink
Fix new rlst for tree
Browse files Browse the repository at this point in the history
  • Loading branch information
skailasa committed Dec 18, 2023
1 parent 7f42e93 commit b74a476
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
3 changes: 2 additions & 1 deletion tree/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ memoffset = "0.6"
rand = "0.8.*"
hyksort = { path = "../hyksort", optional = true }
bempp-traits = { path = "../traits" }
rlst = { git = "https://github.com/linalg-rs/rlst.git" , branch = "legacy"}
rlst-dense = { git = "https://github.com/linalg-rs/rlst.git" }

num = "0.4"

[features]
Expand Down
17 changes: 11 additions & 6 deletions tree/src/implementations/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,22 @@ use num::Float;
use rand::prelude::*;
use rand::SeedableRng;

use rlst::dense::{base_matrix::BaseMatrix, rlst_dynamic_mat, Dynamic, Matrix, VectorContainer};
// use rlst::dense::{base_matrix::BaseMatrix, rlst_dynamic_mat, Dynamic, Matrix, VectorContainer};
use rlst_dense::{
array::Array, base_array::BaseArray, data_container::VectorContainer, rlst_dynamic_array2,
};


/// Alias for an rlst container for point data.
pub type PointsMat<T> = Matrix<T, BaseMatrix<T, VectorContainer<T>, Dynamic>, Dynamic>;
pub type PointsMat<T> = Array<T, BaseArray<T, VectorContainer<T>, 2>, 2>;


/// Points fixture for testing, uniformly samples in each axis from min to max.
///
/// # Arguments
/// * `npoints` - The number of points to sample.
/// # `min` - The minumum coordinate value along each axis.
/// # `max` - The maximum coordinate value along each axis.
/// * `min` - The minumum coordinate value along each axis.
/// * `max` - The maximum coordinate value along each axis.
pub fn points_fixture<T: Float + Scalar + rand::distributions::uniform::SampleUniform>(
npoints: usize,
min: Option<T>,
Expand All @@ -32,7 +37,7 @@ pub fn points_fixture<T: Float + Scalar + rand::distributions::uniform::SampleUn
between = rand::distributions::Uniform::from(T::zero()..T::one());
}

let mut points = rlst_dynamic_mat![T, (npoints, 3)];
let mut points = rlst_dynamic_array2![T, [npoints, 3]];

for i in 0..npoints {
points[[i, 0]] = between.sample(&mut range);
Expand All @@ -57,7 +62,7 @@ pub fn points_fixture_col<T: Float + Scalar + rand::distributions::uniform::Samp
let between1 = rand::distributions::Uniform::from(T::zero()..T::from(0.1).unwrap());
let between2 = rand::distributions::Uniform::from(T::zero()..T::from(500).unwrap());

let mut points = rlst_dynamic_mat![T, (npoints, 3)];
let mut points = rlst_dynamic_array2![T, [npoints, 3]];

for i in 0..npoints {
// One axis has a different sampling
Expand Down
4 changes: 2 additions & 2 deletions tree/src/implementations/impl_domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<T: Float + Default> Domain<T> {
#[cfg(test)]
mod test {
use bempp_traits::types::Scalar;
use rlst::dense::{RawAccess, Shape};
use rlst_dense::traits::{RawAccess, Shape};

use crate::implementations::helpers::{points_fixture, points_fixture_col, PointsMat};

Expand All @@ -80,7 +80,7 @@ mod test {
assert!(domain.diameter.iter().all(|&x| x == domain.diameter[0]));

// Test that all local points are contained within the local domain
let npoints = points.shape().0;
let npoints = points.shape()[0];
for i in 0..npoints {
let point = [points[[i, 0]], points[[i, 1]], points[[i, 2]]];

Expand Down
6 changes: 3 additions & 3 deletions tree/src/implementations/impl_morton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ impl MortonKeyInterface for MortonKey {
#[cfg(test)]
mod test {
use itertools::Itertools;
use rlst::dense::{RawAccess, Shape};
use rlst_dense::traits::{RawAccess, Shape};
use std::vec;

use crate::implementations::helpers::points_fixture;
Expand Down Expand Up @@ -1187,7 +1187,7 @@ mod test {

let mut keys: Vec<MortonKey> = Vec::new();

for i in 0..points.shape().0 {
for i in 0..points.shape()[0] {
let point = [points[[i, 0]], points[[i, 1]], points[[i, 2]]];

keys.push(MortonKey::from_point(&point, &domain, DEEPEST_LEVEL));
Expand Down Expand Up @@ -1471,7 +1471,7 @@ mod test {

let mut keys = Vec::new();

for i in 0..points.shape().0 {
for i in 0..points.shape()[0] {
let point = [points[[i, 0]], points[[i, 1]], points[[i, 2]]];
keys.push(MortonKey::from_point(&point, &domain, DEEPEST_LEVEL))
}
Expand Down
2 changes: 1 addition & 1 deletion tree/src/implementations/impl_single_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ where
#[cfg(test)]
mod test {

use rlst::dense::RawAccess;
use rlst_dense::traits::RawAccess;

use crate::implementations::helpers::{points_fixture, points_fixture_col};

Expand Down

0 comments on commit b74a476

Please sign in to comment.