Matrix

Struct Matrix 

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

Matrix itself

Implementations§

Source§

impl Matrix

Source

pub fn new(data: Vec<Row>) -> Matrix

Return a new matrix with metadata generated.

§Arguments
  • data - A vector that stores multiple Rows.
§Notes

Try to use macros create_matrix!().

use matrix::{create_matrix, create_matrix_row};

let matrix = create_matrix!(
    create_matrix_row!(1.0,2.0),
    create_matrix_row!(3.0,4.0)
);

Trait Implementations§

Source§

impl Add for Matrix

Source§

type Output = Matrix

A new matrix object will be returned.

Source§

fn add(self, rhs: Self) -> Self::Output

Perform additions between two matrices and return a result matrix.

additions

§Example
  use matrix::{create_matrix, create_matrix_row};

  let lhs = create_matrix!(create_matrix_row!(1.0, 5.0), create_matrix_row!(-4.0, 3.0));
  let rhs = create_matrix!(create_matrix_row!(2.0, -1.0), create_matrix_row!(4.0, -1.0));
  let returning_result = create_matrix!(create_matrix_row!(3.0, 4.0), create_matrix_row!(0.0, 2.0));
Source§

impl Debug for Matrix

Source§

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

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

impl Mul<Matrix> for f32

Source§

type Output = Matrix

A new matrix object will be returned.

Source§

fn mul(self, matrix: Matrix) -> Self::Output

Perform multiplication between a matrix and a float number, then return a result matrix.

Source§

impl Mul for Matrix

Source§

type Output = Matrix

A new matrix object will be returned.

Source§

fn mul(self, rhs: Self) -> Self::Output

Perform multiplication between two matrices and return a result matrix.

multiplication_1

§Example 1
use matrix::{create_matrix, create_matrix_row};

let lhs = create_matrix!(create_matrix_row!(1.0, 2.0, 3.0), create_matrix_row!(4.0, 5.0, 6.0));
let rhs = create_matrix!(create_matrix_row!(7.0, 8.0), create_matrix_row!(9.0, 10.0), create_matrix_row!(11.0, 12.0));
let returning_result = create_matrix!(create_matrix_row!(58.0, 64.0), create_matrix_row!(139.0, 154.0));

multiplication_2

§Example 2
use matrix::{create_matrix, create_matrix_row};

let lhs = create_matrix!(create_matrix_row!(1.0, 2.0, 3.0));
let rhs = create_matrix!(create_matrix_row!(4.0), create_matrix_row!(5.0), create_matrix_row!(6.0));
let return_result = create_matrix!(create_matrix_row!(32.0));

multiplication_3

§Example 3
use matrix::{create_matrix, create_matrix_row};

let lhs = create_matrix!(create_matrix_row!(4.0), create_matrix_row!(5.0), create_matrix_row!(6.0));
let rhs = create_matrix!(create_matrix_row!(1.0, 2.0, 3.0));
let return_result = create_matrix!(
    create_matrix_row!(4.0, 8.0, 12.0),
    create_matrix_row!(5.0, 10.0, 15.0),
    create_matrix_row!(6.0, 12.0, 18.0)
);
Source§

impl PartialEq for Matrix

Source§

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

Compare two matrices with same structure and data.

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 Sub for Matrix

Perform substraction between two matrices and return a result matrix.

Source§

type Output = Matrix

A new matrix object will be returned.

Source§

fn sub(self, rhs: Self) -> Self::Output

Perform substraction between two matrices and return a result matrix.

substraction

§Example
use matrix::{create_matrix, create_matrix_row};

let lhs = create_matrix!(create_matrix_row!(4.0, 5.0, 6.0), create_matrix_row!(2.0, 3.0, 4.0));
let rhs = create_matrix!(create_matrix_row!(2.0, 4.0, 6.0), create_matrix_row!(1.0, 2.0, 3.0));
let returning_result = create_matrix!(create_matrix_row!(2.0, 1.0, 0.0), create_matrix_row!(1.0, 1.0, 1.0));

Auto Trait Implementations§

§

impl Freeze for Matrix

§

impl RefUnwindSafe for Matrix

§

impl Send for Matrix

§

impl Sync for Matrix

§

impl Unpin for Matrix

§

impl UnwindSafe for Matrix

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> 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, 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.