bempp_octree::tools

Function is_sorted_array

Source
pub fn is_sorted_array<T: Equivalence + PartialOrd, C: CommunicatorCollectives>(
    arr: &[T],
    comm: &C,
) -> bool
Expand description

Check if an array is sorted.

Examples found in repository?
examples/parsort.rs (line 20)
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
pub fn main() {
    let universe = mpi::initialize().unwrap();
    let world = universe.world();
    let n_per_rank = 1000;

    let mut rng = rand::rngs::StdRng::seed_from_u64(0);

    let keys = generate_random_keys(n_per_rank, &mut rng);

    let arr = parsort(&keys, &world, &mut rng);

    assert!(is_sorted_array(&arr, &world));

    if world.rank() == 0 {
        println!("Array is sorted.");
    }
}