Commit c0638e2a authored by Egor Larionov's avatar Egor Larionov

Replace &Vec with &[] in the api; bump version

parent 4507bd08
[package]
name = "hrbf"
version = "0.1.0"
version = "0.2.0"
authors = ["Egor Larionov <[email protected]>"]
[dependencies]
......
......@@ -60,18 +60,18 @@ where
/// HRBF public interface. It is not necessary to use this trait, but it allows using the HRBF as a
/// trait object. For example this is used to pass HRBF objects between functions in the C API.
pub trait HRBFTrait<T: Real> {
fn fit(&mut self, points: &Vec<Point3<T>>, normals: &Vec<Vector3<T>>) -> bool;
fn fit(&mut self, points: &[Point3<T>], normals: &[Vector3<T>]) -> bool;
fn fit_offset(
&mut self,
points: &Vec<Point3<T>>,
offsets: &Vec<T>,
normals: &Vec<Vector3<T>>,
points: &[Point3<T>],
offsets: &[T],
normals: &[Vector3<T>],
) -> bool;
fn fit_system(
&self,
points: &Vec<Point3<T>>,
potential: &Vec<T>,
normals: &Vec<Vector3<T>>,
points: &[Point3<T>],
potential: &[T],
normals: &[Vector3<T>],
) -> (DMatrix<T>, DVector<T>);
fn eval(&self, p: Point3<T>) -> T;
fn grad(&self, p: Point3<T>) -> Vector3<T>;
......@@ -83,22 +83,22 @@ where
T: Real,
K: Kernel<T> + Default,
{
fn fit(&mut self, points: &Vec<Point3<T>>, normals: &Vec<Vector3<T>>) -> bool {
fn fit(&mut self, points: &[Point3<T>], normals: &[Vector3<T>]) -> bool {
HRBF::fit(self, points, normals)
}
fn fit_offset(
&mut self,
points: &Vec<Point3<T>>,
offsets: &Vec<T>,
normals: &Vec<Vector3<T>>,
points: &[Point3<T>],
offsets: &[T],
normals: &[Vector3<T>],
) -> bool {
HRBF::fit_offset(self, points, offsets, normals)
}
fn fit_system(
&self,
points: &Vec<Point3<T>>,
potential: &Vec<T>,
normals: &Vec<Vector3<T>>,
points: &[Point3<T>],
potential: &[T],
normals: &[Vector3<T>],
) -> (DMatrix<T>, DVector<T>) {
HRBF::fit_system(self, points, potential, normals)
}
......@@ -179,7 +179,7 @@ where
/// Fit the current HRBF to the given data. Return true if successful.
/// NOTE: Currently, points must be the same size as as sites.
#[allow(non_snake_case)]
pub fn fit(&mut self, points: &Vec<Point3<T>>, normals: &Vec<Vector3<T>>) -> bool {
pub fn fit(&mut self, points: &[Point3<T>], normals: &[Vector3<T>]) -> bool {
assert!(normals.len() == points.len());
let num_sites = self.sites.len();
......@@ -209,9 +209,9 @@ where
#[allow(non_snake_case)]
pub fn fit_offset(
&mut self,
points: &Vec<Point3<T>>,
offsets: &Vec<T>,
normals: &Vec<Vector3<T>>,
points: &[Point3<T>],
offsets: &[T],
normals: &[Vector3<T>],
) -> bool {
assert!(normals.len() == points.len());
let num_sites = self.sites.len();
......@@ -240,9 +240,9 @@ where
#[allow(non_snake_case)]
pub fn fit_system(
&self,
points: &Vec<Point3<T>>,
potential: &Vec<T>,
normals: &Vec<Vector3<T>>,
points: &[Point3<T>],
potential: &[T],
normals: &[Vector3<T>],
) -> (DMatrix<T>, DVector<T>) {
assert!(normals.len() == points.len());
assert!(potential.len() == points.len());
......
......@@ -17,7 +17,7 @@ fn cube() -> (Vec<Point3<f64>>, Vec<Vector3<f64>>) {
// Fit an hrbf surface to a unit box
let pts = vec![
// Corners of the box
Point3::new(0.0f64, 0.0, 0.0),
Point3::new(0.0, 0.0, 0.0),
Point3::new(0.0, 0.0, 1.0),
Point3::new(0.0, 1.0, 0.0),
Point3::new(0.0, 1.0, 1.0),
......@@ -147,7 +147,7 @@ fn test_hrbf_fit<K: Kernel<f64> + Default>() {
}
}
// NOTE: pow2 and pow4 kernels generate singular fit matrices whene data and sites are coincident.
// NOTE: pow2 and pow4 kernels generate singular fit matrices when data and sites are coincident.
// It is perhaps still possible to use these for least squares fits. The nice thing about x^2 is
// that it's especially fast to compute so we leave it in the code for future testing.
//
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment