ThreeMat

Struct ThreeMat 

Source
pub struct ThreeMat { /* private fields */ }
Expand description

Three Matrix

Implementations§

Source§

impl ThreeMat

Source

pub fn new(r0: ThreeVec, r1: ThreeVec, r2: ThreeVec) -> ThreeMat

Returns a new ThreeMat from three ThreeVecs

§Arguments
  • r0 - calcify::ThreeVec
  • r1 - calcify::ThreeVec
  • r2 - calcify::ThreeVec
§Example
use calcify::ThreeVec;
use calcify::ThreeMat;
let mat3 = ThreeMat::new(
              ThreeVec::new(1.0,2.0,3.0),
              ThreeVec::new(4.0,5.0,6.0),
              ThreeVec::new(7.0,8.0,9.0)
           );
Source

pub fn from(slice: &[ThreeVec]) -> ThreeMat

Returns a new ThreeMat from a slice

§Arguments
§Panics
  • slice length < 3
Source

pub fn random(max: f64) -> ThreeMat

Returns a new ThreeMat with three random ThreeVecs using calcify::ThreeVec::random(max: f64)

§Arguments
  • max - f64: The absolute maximum value of each individule componant of the constituent ThreeVec
§Example
use calcify::ThreeMat;
let mat3 = ThreeMat::random(10.0);
Source

pub fn eye() -> ThreeMat

Returns a new ThreeMat identity matrix

§Example
use calcify::ThreeMat;
let mat3 = ThreeMat::eye();

assert_eq!(*mat3.r1().x1(),1.0);
Source

pub fn zero() -> ThreeMat

Returns a new ThreeMat zero matrix

§Example
use calcify::ThreeMat;
let mat3 = ThreeMat::zero();

assert_eq!(*mat3.r1().x1(),0.0);
Source

pub fn one() -> ThreeMat

Returns a new ThreeMat one matrix

§Example
use calcify::ThreeMat;
let mat3 = ThreeMat::one();

assert_eq!(*mat3.r1().x1(),1.0);
Source

pub fn r0(&self) -> &ThreeVec

Returns a reference to the first row of the matrix.

§Example
use calcify::ThreeVec;
use calcify::ThreeMat;
let mat3 = ThreeMat::new(
              ThreeVec::new(1.0,2.0,3.0),
              ThreeVec::new(4.0,5.0,6.0),
              ThreeVec::new(7.0,8.0,9.0)
           );
let row_zero: ThreeVec = *mat3.r0();
let element_zero_zero: f64 = *mat3.r0().x0();
assert_eq!(row_zero,ThreeVec::new(1.0,2.0,3.0));
assert_eq!(element_zero_zero,1.0);
Source

pub fn r1(&self) -> &ThreeVec

Returns a reference to the second row of the matrix.

§Example
use calcify::ThreeVec;
use calcify::ThreeMat;
let mat3 = ThreeMat::new(
              ThreeVec::new(1.0,2.0,3.0),
              ThreeVec::new(4.0,5.0,6.0),
              ThreeVec::new(7.0,8.0,9.0)
           );
let row_one: ThreeVec = *mat3.r1();
let element_one_one: f64 = *mat3.r1().x1();
assert_eq!(row_one,ThreeVec::new(4.0,5.0,6.0));
assert_eq!(element_one_one,5.0);
Source

pub fn r2(&self) -> &ThreeVec

Returns a reference to the third row of the matrix.

§Example
use calcify::ThreeVec;
use calcify::ThreeMat;
let mat3 = ThreeMat::new(
              ThreeVec::new(1.0,2.0,3.0),
              ThreeVec::new(4.0,5.0,6.0),
              ThreeVec::new(7.0,8.0,9.0)
           );
let row_two: ThreeVec = *mat3.r2();
let element_two_two: f64 = *mat3.r2().x2();
assert_eq!(row_two,ThreeVec::new(7.0,8.0,9.0));
assert_eq!(element_two_two,9.0);
Source

pub fn c0(&self) -> ThreeVec

Returns a new memory ThreeVec of the first column of the matrix.

§Example
use calcify::ThreeVec;
use calcify::ThreeMat;
let mat3 = ThreeMat::new(
              ThreeVec::new(1.0,2.0,3.0),
              ThreeVec::new(4.0,5.0,6.0),
              ThreeVec::new(7.0,8.0,9.0)
           );
let col_one: ThreeVec = mat3.c0();
let element_one_one: f64 = *mat3.c0().x0();
assert_eq!(col_one,ThreeVec::new(1.0,4.0,7.0));
assert_eq!(element_one_one,1.0);
Source

pub fn c1(&self) -> ThreeVec

Source

pub fn c2(&self) -> ThreeVec

Trait Implementations§

Source§

impl Add for ThreeMat

Source§

type Output = ThreeMat

The resulting type after applying the + operator.
Source§

fn add(self, other: ThreeMat) -> ThreeMat

Performs the + operation. Read more
Source§

impl AddAssign for ThreeMat

Source§

fn add_assign(&mut self, other: ThreeMat)

Performs the += operation. Read more
Source§

impl Clone for ThreeMat

Source§

fn clone(&self) -> ThreeMat

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ThreeMat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deserializable for ThreeMat

Source§

fn from_json(s: &str) -> Result<Self, Box<dyn Error>>

Return Self from string
Source§

fn from_msg(bytes: &[u8]) -> Result<(Self, &[u8]), Box<dyn Error>>

Return a tuple of Self and a &u8 of remaining unparsed bytes from a byte array
Source§

impl Display for ThreeMat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Mul<ThreeMat> for f64

Source§

type Output = ThreeMat

The resulting type after applying the * operator.
Source§

fn mul(self, vec: ThreeMat) -> ThreeMat

Performs the * operation. Read more
Source§

impl Mul<ThreeVec> for ThreeMat

Source§

fn mul(self, other: ThreeVec) -> ThreeVec

Matrix multiplication with vector

§Note

Only works in one direction ThreeMat*ThreeVec, implying ThreeVec as a column vector.

§Example
use calcify::ThreeMat;
use calcify::ThreeVec;

let mat3 = ThreeMat::new(ThreeVec::new(1.0,2.0,3.0),
                            ThreeVec::new(1.0,2.0,3.0),
                            ThreeVec::new(1.0,2.0,3.0));

assert_eq!(
    mat3*ThreeVec::new(2.0,2.0,2.0),
    ThreeVec::new(12.0,12.0,12.0)
);
Source§

type Output = ThreeVec

The resulting type after applying the * operator.
Source§

impl Mul<f64> for ThreeMat

Source§

type Output = ThreeMat

The resulting type after applying the * operator.
Source§

fn mul(self, coef: f64) -> ThreeMat

Performs the * operation. Read more
Source§

impl Mul for ThreeMat

Source§

fn mul(self, other: ThreeMat) -> ThreeMat

Matrix multiplication

§Example
use calcify::ThreeMat;
use calcify::ThreeVec;

let mat3 = ThreeMat::new(ThreeVec::new(1.0,2.0,3.0),
                            ThreeVec::new(4.0,5.0,6.0),
                            ThreeVec::new(7.0,8.0,9.0));

assert_eq!(
    mat3*mat3,
    ThreeMat::new(ThreeVec::new(30.0,36.0,42.0),
                ThreeVec::new(66.0,81.0,96.0),
                ThreeVec::new(102.0,126.0,150.0)));
Source§

type Output = ThreeMat

The resulting type after applying the * operator.
Source§

impl Neg for ThreeMat

Source§

type Output = ThreeMat

The resulting type after applying the - operator.
Source§

fn neg(self) -> ThreeMat

Performs the unary - operation. Read more
Source§

impl PartialEq for ThreeMat

Source§

fn eq(&self, other: &ThreeMat) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serializable for ThreeMat

Source§

fn to_json(&self) -> String

Return object intensive json string Read more
Source§

fn to_msg(&self) -> Result<Vec<u8>, ValueWriteError>

Return Result wrapped Vec in MsgPack Format is not like to_json it is array intensive not object Read more
Source§

impl Sub for ThreeMat

Source§

type Output = ThreeMat

The resulting type after applying the - operator.
Source§

fn sub(self, other: ThreeMat) -> ThreeMat

Performs the - operation. Read more
Source§

impl SubAssign for ThreeMat

Source§

fn sub_assign(&mut self, other: ThreeMat)

Performs the -= operation. Read more
Source§

impl Copy for ThreeMat

Source§

impl StructuralPartialEq for ThreeMat

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.