pub struct Vector<T> {
pub content: Vec<T>,
/* private fields */
}
Expand description
Math Vector
Fields§
§content: Vec<T>
Implementations§
Source§impl<T> Vector<T>
impl<T> Vector<T>
Sourcepub fn new(content: Vec<T>, column_or_row: bool) -> Self
pub fn new(content: Vec<T>, column_or_row: bool) -> Self
Create the Vector
§Examples
use lemonmath::vectors::Vector;
let x = Vector::new(vec![1.0, 2.0, 3.0, 4.0, 5.0], true);
assert_eq!(x.content, vec![1.0, 2.0, 3.0, 4.0, 5.0]);
Sourcepub fn push(&mut self, value: T)
pub fn push(&mut self, value: T)
Push new values into the vector
§Examples
use lemonmath::vectors::Vector;
let mut vector = Vector::new(vec![1.0, 2.0, 3.0, 4.0, 5.0], true);
vector.push(6.0);
assert_eq!(vector.content, vec![1.0, 2.0, 3.0, 4.0, 5.0, 6.0]);
Sourcepub fn transpose(&mut self)
pub fn transpose(&mut self)
Switch between column and row vector
§Examples
use lemonmath::vectors::Vector;
let mut vector1 = Vector::new(vec![1.0, 2.0, 3.0, 4.0, 5.0], true);
let vector2 = Vector::new(vec![1.0, 2.0, 3.0, 4.0, 5.0], false);
vector1.transpose();
assert_eq!(format!("{}", vector1), format!("{}", vector2));
Trait Implementations§
Source§impl<T: AddAssign + Default + Mul + Mul<Output = T> + Copy + Display> Mul for Vector<T>
impl<T: AddAssign + Default + Mul + Mul<Output = T> + Copy + Display> Mul for Vector<T>
Source§impl<T: PartialOrd> PartialOrd for Vector<T>
impl<T: PartialOrd> PartialOrd for Vector<T>
impl<T> StructuralPartialEq for Vector<T>
Auto Trait Implementations§
impl<T> Freeze for Vector<T>
impl<T> RefUnwindSafe for Vector<T>where
T: RefUnwindSafe,
impl<T> Send for Vector<T>where
T: Send,
impl<T> Sync for Vector<T>where
T: Sync,
impl<T> Unpin for Vector<T>where
T: Unpin,
impl<T> UnwindSafe for Vector<T>where
T: UnwindSafe,
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