pub struct Model<Point: PartialEq> { /* private fields */ }
Expand description

A set of balls model.

Implementations

Build a new model.

Load an existing model.

use fluent_data::{Model, model::BallData, space};

fn main() {
    let data = vec![
        BallData::new(vec![4.], 3., 1.),
        BallData::new(vec![5.], 2., 2.),
        BallData::new(vec![3.], 3., 3.),
    ];
    let model = Model::load(space::euclid_dist, data);
}

Gets an iterator over the balls of this model.

Gets the balls that most probably include the given point.

use fluent_data::{Model, model::BallData, space, neighborhood::{GetNeighborhood, Neighborhood}};

fn main() {
    let data = vec![
        BallData::new(vec![4.], 3., 1.),
        BallData::new(vec![5.], 2., 2.),
        BallData::new(vec![3.], 3., 3.),
    ];
    let model = Model::load(space::euclid_dist, data.clone());
    let neighborhood = model.predict(&vec![6.]);
    if let Neighborhood::Two(n1, n2) = neighborhood {
        assert_eq!(&data[1], n1.coord());
        assert_eq!(1./2., n1.dist());
        assert_eq!(&data[0], n2.coord());
        assert_eq!(4./3., n2.dist());
    } else {
        panic!()
    }
}

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.