extending R with Rust
Scientific computing with Rust is growing
A little skill goes a long way
#[extendr] fn gh_encode(x: f64, y: f64, length: usize) -> String { let coord = Coord { x, y }; encode(coord, length).expect("Failed to encode the geohash") }
#[extendr] fn gh_encode(x: f64, y: f64, length: usize) -> String { let coord = Coord { x, y }; encode(coord, length).expect("Failed to encode the geohash") }
#[extendr] fn gh_encode(x: f64, y: f64, length: usize) -> String { let coord = Coord { x, y }; encode(coord, length).expect("Failed to encode the geohash") }
#[extendr] fn gh_encode(x: f64, y: f64, length: usize) -> String { let coord = Coord { x, y }; encode(coord, length).expect("Failed to encode the geohash") }
#[extendr]
fn gh_encode(x: &[f64], y: &[f64], length: usize) -> Vec<String> {
x
.into_iter()
.zip(y.into_iter())
.map(|(xi, yi)| {
let coord = Coord { x: xi, y: yi };
encode(coord, length)
.expect("Failed to encode the geohash")
})
.collect::<Vec<_>()
}
#[extendr]
fn gh_encode(x: &[f64], y: &[f64], length: usize) -> Vec<String> {
x
.into_iter()
.zip(y.into_iter())
.map(|(xi, yi)| {
let coord = Coord { x: xi, y: yi };
encode(coord, length)
.expect("Failed to encode the geohash")
})
.collect::<Vec<_>()
}
#[extendr]
fn gh_encode(x: &[f64], y: &[f64], length: usize) -> Vec<String> {
x
.into_iter()
.zip(y.into_iter())
.map(|(xi, yi)| {
let coord = Coord { x: xi, y: yi };
encode(coord, length)
.expect("Failed to encode the geohash")
})
.collect::<Vec<_>()
}
#[extendr]
fn gh_encode(x: &[f64], y: &[f64], length: usize) -> Vec<String> {
x
.into_iter()
.zip(y.into_iter())
.map(|(xi, yi)| {
let coord = Coord { x: xi, y: yi };
encode(coord, length)
.expect("Failed to encode the geohash")
})
.collect::<Vec<_>()
}
#[extendr]
fn gh_encode(x: &[f64], y: &[f64], length: usize) -> Vec<String> {
x
.into_iter()
.zip(y.into_iter())
.map(|(xi, yi)| {
let coord = Coord { x: xi, y: yi };
encode(coord, length)
.expect("Failed to encode the geohash")
})
.collect::<Vec<_>()
}
#[extendr]
fn gh_encode(x: &[f64], y: &[f64], length: usize) -> Vec<String> {
x
.into_iter()
.zip(y.into_iter())
.map(|(xi, yi)| {
let coord = Coord { x: xi, y: yi };
encode(coord, length)
.expect("Failed to encode the geohash")
})
.collect::<Vec<_>()
}
#[extendr]
fn gh_encode(x: &[f64], y: &[f64], length: usize) -> Vec<String> {
x
.into_iter()
.zip(y.into_iter())
.par_bridge() // convert into a parallel iterator
.with_min_len(1024) // set minimum parallel chunk length
.map(|(xi, yi)| {
let coord = Coord { x: xi, y: yi };
encode(coord, length)
.expect("Failed to encode the geohash")
})
.collect::<Vec<_>()
}