pub struct Vector<const N: usize>(/* private fields */);
Implementations§
Source§impl<const N: usize> Vector<N>
impl<const N: usize> Vector<N>
Sourcepub fn try_from(values: Vec<f32>) -> Result<Self, Vec<f32>>
pub fn try_from(values: Vec<f32>) -> Result<Self, Vec<f32>>
Try to create a Vector from a Vec<f32>
.
§Arguments
values
- The vector to create the Vector from, must be of size N.
§Returns
Ok(Vector<N>)
- The Vector created from theVec<f32>
.Err(Vec<f32>)
- TheVec<f32>
is not the correct size.
§Examples
use vector_lite::Vector;
let vec = vec![1.0, 2.0, 3.0];
let vector: Vector<3> = Vector::try_from(vec).unwrap();
assert_eq!(vector.into_inner(), vec![1.0, 2.0, 3.0]);
Sourcepub fn into_inner(self) -> Vec<f32>
pub fn into_inner(self) -> Vec<f32>
Get the inner vector.
pub fn as_slice(&self) -> &[f32; N]
pub fn sq_euc_dist(&self, vector: &Vector<N>) -> f32
pub fn cosine_similarity(&self, vector: &Vector<N>) -> f32
Trait Implementations§
Source§impl<'__de, const N: usize, __Context> BorrowDecode<'__de, __Context> for Vector<N>
impl<'__de, const N: usize, __Context> BorrowDecode<'__de, __Context> for Vector<N>
Source§fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>(
decoder: &mut __D,
) -> Result<Self, DecodeError>
fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
impl<const N: usize> Eq for Vector<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for Vector<N>
impl<const N: usize> RefUnwindSafe for Vector<N>
impl<const N: usize> Send for Vector<N>
impl<const N: usize> Sync for Vector<N>
impl<const N: usize> Unpin for Vector<N>
impl<const N: usize> UnwindSafe for Vector<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more