Struct custos_math::Matrix

source ·
pub struct Matrix<'a, T = f32, D: Device = CPU, S: Shape = ()> {
    pub data: Buffer<'a, T, D, S>,
    pub dims: (usize, usize),
}
Expand description

A matrix using Buffer described with rows and columns

Example

The following example creates a zeroed (or values set to default) Matrix with the given dimensions.

use custos::CPU;
use custos_math::Matrix;

let device = CPU::new();
let m = Matrix::<i32>::new(&device, (5, 8));

assert_eq!(m.rows(), 5);
assert_eq!(m.cols(), 8);
assert_eq!(m.size(), 5*8);
assert_eq!(m.read(), vec![0; 5*8])

Fields§

§data: Buffer<'a, T, D, S>§dims: (usize, usize)

Implementations§

source§

impl<'a, T, D: Device, S: Shape> Matrix<'a, T, D, S>

source

pub fn new(device: &'a D, dims: (usize, usize)) -> Matrix<'a, T, D, S>where D: Alloc<'a, T, S>,

Returns an empty matrix with the specified dimensions (rows, cols).

Example
use custos::CPU;
use custos_math::Matrix;

let device = CPU::new();
let m = Matrix::<f64>::new(&device, (20, 10));

assert_eq!(m.size(), 20*10);
assert_eq!(m.read(), vec![0.0; 20*10])
source

pub fn device(&self) -> &'a D

source

pub fn as_buf(&self) -> &Buffer<'a, T, D, S>

Returns a reference to the underlying buffer.

Example
use custos::{CPU, Read};
use custos_math::Matrix;

let device = CPU::new();
let a = Matrix::from((&device, (2, 3), [1., 2., 3., 3., 2., 1.,]));
let read = a.read();
assert_eq!(vec![1., 2., 3., 3., 2., 1.,], read);
source

pub fn to_buf(self) -> Buffer<'a, T, D, S>

source

pub fn as_buf_mut(&mut self) -> &mut Buffer<'a, T, D, S>

Returns a mutable reference to the underlying buffer.

source

pub fn dims(&self) -> (usize, usize)

source

pub fn reshape(&mut self, dims: (usize, usize))

source

pub fn rows(&self) -> usize

Returns the row count of the matrix.

Example
use custos::CPU;
use custos_math::Matrix;

let device = CPU::new();
let matrix = Matrix::<i32>::new(&device, (2, 5));
assert_eq!(matrix.rows(), 2)
source

pub fn cols(&self) -> usize

Returns the column count of the matrix.

Example
use custos::CPU;
use custos_math::Matrix;

let device = CPU::new();
let matrix = Matrix::<i32>::new(&device, (2, 5));
assert_eq!(matrix.cols(), 5)
source

pub fn size(&self) -> usize

Returns the number of elements in the matrix: rows * cols

Example
use custos::CPU;
use custos_math::Matrix;

let device = CPU::new();
let matrix = Matrix::<u16>::new(&device, (4, 12));
assert_eq!(matrix.size(), 48)
source

pub fn as_slice(&self) -> &[T] where D: MainMemory,

source

pub fn as_mut_slice(&mut self) -> &mut [T] where D: MainMemory,

source

pub fn read(&'a self) -> D::Read<'a>where T: Default + Copy, D: Read<T, D, S>,

Uses VecRead and current global device to read Matrix

Example
use custos::CPU;
use custos_math::Matrix;

let device = CPU::new();

let a = Matrix::from((&device, (2, 2), [5, 7, 2, 10,]));
assert_eq!(a.read(), vec![5, 7, 2, 10])
source

pub fn read_to_vec(&self) -> Vec<T>where T: Default + Copy, D: Read<T, D, S>,

Uses VecRead and current global device to read Matrix

Example
use custos::CPU;
use custos_math::Matrix;

let device = CPU::new();

let a = Matrix::from((&device, (2, 2), [5, 7, 2, 10,]));
assert_eq!(a.read(), vec![5, 7, 2, 10])
source

pub fn shallow(&self) -> Matrix<'a, T, D, S>where D::Ptr<T, S>: ShallowCopy,

Creates a shallow copy of &self.

source

pub fn shallow_or_clone(&self) -> Matrix<'a, T, D, S>where T: Clone, D::Ptr<T, S>: ShallowCopy, D: CloneBuf<'a, T, S>,

Creates a shallow copy or a deep copy of &self, depening on whether the realloc feature is activated.

source§

impl<'a, T, D: Device, S: Shape> Matrix<'a, T, D, S>

source

pub fn to_dims<O: Shape>(self) -> Matrix<'a, T, D, O>where D: ToDim<T, S, O>,

Converts a (non stack allocated) Buffer with no shape to a Buffer with shape O.

source§

impl<T, D: IsShapeIndep, S: Shape> Matrix<'_, T, D, S>

source

pub fn as_dims<'b, O: Shape>(&self) -> &Matrix<'b, T, D, O>

source

pub fn as_dims_mut<'b, O: Shape>(&mut self) -> &mut Matrix<'b, T, D, O>

source§

impl<'a, T, D: ActivationOps<T, S>, S: Shape> Matrix<'a, T, D, S>

source

pub fn tanh(&self) -> Matrix<'a, T, D, S>

source

pub fn tanh_grad(&self) -> Matrix<'a, T, D, S>

source

pub fn relu(&self) -> Matrix<'a, T, D, S>

source

pub fn relu_mut(&mut self)

source

pub fn relu_grad(&self) -> Matrix<'a, T, D, S>

source

pub fn relu_grad_mut(&mut self)

source

pub fn sigmoid(&self) -> Matrix<'a, T, D, S>

source

pub fn sigmoid_grad(&self) -> Matrix<'a, T, D, S>

uses pre-computed sigmoid activation

source§

impl<'a, T, S: Shape, D: CCEOp<T, S>> Matrix<'a, T, D, S>

source

pub fn cce(&self, targets: &Matrix<'a, T, D, S>) -> (T, Matrix<'a, T, D, S>)

source

pub fn cce_loss(&self, targets: &Matrix<'_, T, D, S>) -> T

source

pub fn cce_grad(&self, targets: &Matrix<'a, T, D, S>) -> Matrix<'a, T, D, S>

source§

impl<'a, T, D: SoftmaxOps<T>> Matrix<'a, T, D>

source

pub fn softmax(&self) -> Matrix<'a, T, D>

source

pub fn softmax_grad(&self, activated: &Matrix<'_, T, D>) -> Matrix<'a, T, D>

source§

impl<'a, T, S: Shape, D: ClipOp<T, S>> Matrix<'a, T, D, S>

source

pub fn clip(&self, min: T, max: T) -> Matrix<'_, T, D, S>

source§

impl<'a, T, D: DiagflatOp<T>> Matrix<'a, T, D>

source

pub fn diagflat(&self) -> Matrix<'a, T, D>

source§

impl<'a, T: Float, S: Shape, D: FnsOps<T, S, D>> Matrix<'a, T, D, S>

source

pub fn exp(&self) -> Self

source

pub fn ln(&self) -> Self

source

pub fn neg(&self) -> Self

source

pub fn powf(&self, rhs: T) -> Self

source

pub fn powi(&self, rhs: i32) -> Self

source§

impl<'a, T, D: Device, LS: Shape> Matrix<'a, T, D, LS>

source

pub fn gemm<RS: Shape, OS: Shape>( &self, rhs: &Matrix<'a, T, D, RS> ) -> Matrix<'a, T, D, OS>where D: Gemm<T, LS, RS, OS, D>,

Matrix multiplication. Uses current global device.

Example
use custos::CPU;
use custos_math::Matrix;

let device = CPU::new();

let a = Matrix::from((&device, (2, 3), [1., 2., 3., 4., 5., 6.,]));
let b = Matrix::from((&device, (3, 2), [6., 5., 4., 3., 2., 1.,]));

let c = a.gemm(&b);
println!("c: {c:?}");

assert_eq!(c.read(), vec![20., 14., 56., 41.,]);
source§

impl<'a, T, D: MaxOps<T>> Matrix<'a, T, D>

source

pub fn max(&self) -> T

source

pub fn max_rows(&self) -> Matrix<'a, T, D>

source

pub fn max_cols(&self) -> Matrix<'a, T, D>

source§

impl<'a, T, LS: Shape, D: Device> Matrix<'a, T, D, LS>

source

pub fn add_row<RS: Shape>( &self, rhs: &Matrix<'_, T, D, RS> ) -> Matrix<'a, T, D, LS>where D: RowOp<T, LS, RS>,

source

pub fn add_row_mut<RS: Shape>(&mut self, rhs: &Matrix<'a, T, D, RS>)where D: RowOp<T, LS, RS>,

source§

impl<'a, T, D, S> Matrix<'a, T, D, S>where D: AdditionalOps<T, S>, S: Shape,

source

pub fn adds(&self, rhs: T) -> Self

source

pub fn subs(&self, rhs: T) -> Self

source

pub fn muls(&self, rhs: T) -> Self

source

pub fn divs(&self, rhs: T) -> Self

source§

impl<'a, T, IS: Shape, D: SumOps<T, IS>> Matrix<'a, T, D, IS>

source

pub fn sum(&self) -> T

source

pub fn mean(&self) -> T

source§

impl<'a, T, D: Device, IS: Shape> Matrix<'a, T, D, IS>

source

pub fn sum_rows<OS: Shape>(&self) -> Matrix<'a, T, D, OS>where D: SumOverOps<T, IS, OS>,

source

pub fn sum_cols<OS: Shape>(&self) -> Matrix<'a, T, D, OS>where D: SumOverOps<T, IS, OS>,

source§

impl<'a, T, IS: Shape, D: Device> Matrix<'a, T, D, IS>

source

pub fn T<OS: Shape>(&self) -> Matrix<'a, T, D, OS>where D: TransposeOp<T, IS, OS>,

source§

impl<'a, T, S: Shape, D: RandOp<T, S>> Matrix<'a, T, D, S>

source

pub fn rand(&mut self, lo: T, hi: T)

Methods from Deref<Target = Buffer<'a, T, D, S>>§

source

pub fn copy(&self) -> Buffer<'a, T, (), ()>where T: Copy,

source

pub fn item(&self) -> Twhere T: Copy,

Used if the Buffer contains only a single value. By derefencing this Buffer, you obtain this value as well (which is probably preferred).

Example
use custos::Buffer;

let x: Buffer<f32, _> = 7f32.into();
assert_eq!(*x, 7.);
assert_eq!(x.item(), 7.);
source

pub fn device(&self) -> &'a D

source

pub fn read(&'a self) -> <D as Read<T, D, S>>::Read<'a>where T: Clone + Default, D: Read<T, D, S>,

source

pub fn read_to_vec(&self) -> Vec<T, Global>where D: Read<T, D, S>, T: Default + Clone,

Reads the contents of the buffer and writes them into a vector. If it is certain whether a CPU, or an unified CPU + OpenCL Buffer, is used, calling .as_slice() (or deref/mut to &/mut [&T]) is probably preferred.

Example
use custos::{CPU, Buffer};

let device = CPU::new();
let buf = Buffer::from((&device, [1, 2, 3, 4]));

assert_eq!(buf.read_to_vec(), vec![1, 2, 3, 4]);
source

pub fn write(&mut self, data: &[T])where T: Clone, D: WriteBuf<T, D, S>,

Writes a slice to the Buffer. With a CPU buffer, the slice is just copied to the slice of the buffer.

source

pub fn len(&self) -> usize

Returns the number of elements contained in Buffer.

Example
use custos::{CPU, Buffer};

let device = CPU::new();
let a = Buffer::<i32, _>::new(&device, 10);
assert_eq!(a.len(), 10)
source

pub unsafe fn shallow(&self) -> Buffer<'a, T, D, S>where <D as Device>::Ptr<T, S>: ShallowCopy,

Creates a shallow copy of &self.

Safety

Itself, this function does not need to be unsafe. However, declaring this function as unsafe highlights the violation of creating two or more owners for one resource. Furthermore, the resulting Buffer can outlive self.

source

pub unsafe fn shallow_or_clone(&self) -> Buffer<'a, T, D, S>where <D as Device>::Ptr<T, S>: ShallowCopy, T: Clone, D: CloneBuf<'a, T, S>,

Returns a shallow copy of &self, if the realloc feature is deactivated. If the realloc feature is activated, it returns a deep copy / clone.

Safety

Itself, this function does not need to be unsafe. However, declaring this function as unsafe highlights the violation of possibly creating two or more owners for one resource. Furthermore, the resulting Buffer can outlive self.

source

pub fn id(&self) -> Ident

source

pub fn as_dims<'b, O>(&self) -> &Buffer<'b, T, D, O>where O: Shape,

source

pub fn as_dims_mut<'b, O>(&mut self) -> &mut Buffer<'b, T, D, O>where O: Shape,

source

pub fn ptrs(&self) -> (*const T, *mut c_void, u64)

Returns all types of pointers. (host, OpenCL, CUDA)

source

pub fn ptrs_mut(&mut self) -> (*mut T, *mut c_void, u64)

Returns all types of pointers. (host, OpenCL, CUDA)

source

pub fn is_empty(&self) -> bool

Returns true if Buffer is created without a slice.

Example
use custos::{CPU, Buffer};

let a = Buffer::<i32, ()>::from(5);
assert!(a.is_empty())
source

pub fn clear(&mut self)where D: ClearBuf<T, D, ()>,

Sets all elements in Buffer to the default value.

source

pub fn cl_ptr(&self) -> *mut c_void

source

pub fn cu_ptr(&self) -> u64

Returns a non null CUDA pointer

source

pub fn as_slice(&self) -> &[T]

Returns a CPU slice. This does not work with CUDA or raw OpenCL buffers.

source

pub fn as_mut_slice(&mut self) -> &mut [T]

Returns a mutable CPU slice.

source

pub fn host_ptr(&self) -> *const T

Returns a non null host pointer

source

pub fn host_ptr_mut(&mut self) -> *mut T

Returns a non null host pointer

Trait Implementations§

source§

impl<'a, T, D, S: Shape> Add<&Matrix<'a, T, D, S>> for &Matrix<'a, T, D, S>where D: BaseOps<T, S>,

§

type Output = Matrix<'a, T, D, S>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<'a, T, D, S: Shape> Add<&Matrix<'a, T, D, S>> for Matrix<'a, T, D, S>where D: BaseOps<T, S>,

§

type Output = Matrix<'a, T, D, S>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<'a, T, D, S: Shape> Add<Matrix<'a, T, D, S>> for &Matrix<'a, T, D, S>where D: BaseOps<T, S>,

§

type Output = Matrix<'a, T, D, S>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Matrix<'_, T, D, S>) -> Self::Output

Performs the + operation. Read more
source§

impl<'a, T, D, S: Shape> Add<Matrix<'a, T, D, S>> for Matrix<'a, T, D, S>where D: BaseOps<T, S>,

§

type Output = Matrix<'a, T, D, S>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<'a, T, D, S: Shape> Add<T> for &Matrix<'a, T, D, S>where D: AdditionalOps<T, S>,

§

type Output = Matrix<'a, T, D, S>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<'a, T, D> Add<T> for Matrix<'a, T, D>where D: AdditionalOps<T>,

§

type Output = Matrix<'a, T, D, ()>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<T, D, S: Shape> AddAssign<&Matrix<'_, T, D, S>> for Matrix<'_, T, D, S>where D: AssignOps<T, S, D>,

source§

fn add_assign(&mut self, rhs: &Self)

Performs the += operation. Read more
source§

impl<T, D, S: Shape> AddAssign<Matrix<'_, T, D, S>> for Matrix<'_, T, D, S>where D: AssignOps<T, S, D>,

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl<'a, T, S, D> AddAssign<T> for Matrix<'a, T, D, S>where S: Shape, D: ScalarAssign<T, S>,

source§

fn add_assign(&mut self, rhs: T)

Performs the += operation. Read more
source§

impl<'a, T> AsClCvoidPtr for &Matrix<'a, T, OpenCL>

source§

impl<'a, T> AsClCvoidPtr for Matrix<'a, T, OpenCL>

source§

impl<'a, T, S, D> Clone for Matrix<'a, T, D, S>where T: Clone, S: Shape, D: CloneBuf<'a, T, S>,

source§

fn clone(&self) -> Self

Returns a copy 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<'a, T: Default + Copy + Debug, D> Debug for Matrix<'a, T, D>where D: Read<T, D> + 'a,

source§

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

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

impl<T, D: Device> Default for Matrix<'_, T, D>where D::Ptr<T, ()>: Default,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'a, T, D: Device, S: Shape> Deref for Matrix<'a, T, D, S>

§

type Target = Buffer<'a, T, D, S>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'a, T, D: Device, S: Shape> DerefMut for Matrix<'a, T, D, S>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<'a, T, S: Shape, D: BaseOps<T, S>> Div<&Matrix<'a, T, D, S>> for &Matrix<'a, T, D, S>

§

type Output = Matrix<'a, T, D, S>

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl<'a, T, S: Shape, D: AdditionalOps<T, S>> Div<T> for &Matrix<'a, T, D, S>

§

type Output = Matrix<'a, T, D, S>

The resulting type after applying the / operator.
source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
source§

impl<'a, T, S: Shape, D: AdditionalOps<T, S>> Div<T> for Matrix<'a, T, D, S>

§

type Output = Matrix<'a, T, D, S>

The resulting type after applying the / operator.
source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
source§

impl<T, S, D> DivAssign<T> for Matrix<'_, T, D, S>where S: Shape, D: ScalarAssign<T, S>,

source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
source§

impl<'a, T> From<(&'a CPU, *mut T, (usize, usize))> for Matrix<'a, T>

source§

fn from((cpu, ptr, dims): (&'a CPU, *mut T, (usize, usize))) -> Self

Converts to this type from the input type.
source§

impl<'a, 'b, T> From<(&'a CUDA, Matrix<'b, T, CPU, ()>)> for Matrix<'a, T, CUDA>

source§

fn from(device_matrix: (&'a CUDA, Matrix<'b, T>)) -> Self

Converts to this type from the input type.
source§

impl<'a, T: Copy, D: Alloc<'a, T>> From<(&'a D, (usize, usize))> for Matrix<'a, T, D>

source§

fn from((device, dims): (&'a D, (usize, usize))) -> Self

Converts to this type from the input type.
source§

impl<'a, T: Copy, D: Alloc<'a, T> + IsShapeIndep> From<(&'a D, (usize, usize), &[T])> for Matrix<'a, T, D>

source§

fn from(dims_slice: (&'a D, (usize, usize), &[T])) -> Self

Converts to this type from the input type.
source§

impl<'a, T: Copy, D: Alloc<'a, T> + IsShapeIndep> From<(&'a D, (usize, usize), &Vec<T, Global>)> for Matrix<'a, T, D>

source§

fn from(dims_slice: (&'a D, (usize, usize), &Vec<T>)) -> Self

Converts to this type from the input type.
source§

impl<'a, T: Copy, D: Alloc<'a, T> + IsShapeIndep, const N: usize> From<(&'a D, (usize, usize), [T; N])> for Matrix<'a, T, D>

source§

fn from((device, dims, slice): (&'a D, (usize, usize), [T; N])) -> Self

Converts to this type from the input type.
source§

impl<'a, T: Copy, D: Alloc<'a, T> + IsShapeIndep> From<(&'a D, (usize, usize), Vec<T, Global>)> for Matrix<'a, T, D>

source§

fn from(dims_slice: (&'a D, (usize, usize), Vec<T>)) -> Self

Converts to this type from the input type.
source§

impl<'a, T: Copy, D: Alloc<'a, T>> From<(&'a D, usize, usize)> for Matrix<'a, T, D>

source§

fn from((device, rows, cols): (&'a D, usize, usize)) -> Self

Converts to this type from the input type.
source§

impl<'a, T: Copy, D: Alloc<'a, T> + IsShapeIndep> From<(&'a D, usize, usize, &[T])> for Matrix<'a, T, D>

source§

fn from(dims_slice: (&'a D, usize, usize, &[T])) -> Self

Converts to this type from the input type.
source§

impl<'a, T: Copy, D: Alloc<'a, T> + IsShapeIndep, const N: usize> From<(&'a D, usize, usize, [T; N])> for Matrix<'a, T, D>

source§

fn from(dims_slice: (&'a D, usize, usize, [T; N])) -> Self

Converts to this type from the input type.
source§

impl<'a, T: Copy, D: Alloc<'a, T> + IsShapeIndep> From<(&'a D, usize, usize, Vec<T, Global>)> for Matrix<'a, T, D>

source§

fn from(dims_slice: (&'a D, usize, usize, Vec<T>)) -> Self

Converts to this type from the input type.
source§

impl<'a, 'b, T> From<(&'a OpenCL, Matrix<'b, T, CPU, ()>)> for Matrix<'a, T, OpenCL>

source§

fn from((device, matrix): (&'a OpenCL, Matrix<'b, T>)) -> Self

Converts to this type from the input type.
source§

impl<'a, T> From<(*mut T, (usize, usize))> for Matrix<'a, T>

source§

fn from((ptr, dims): (*mut T, (usize, usize))) -> Self

Converts to this type from the input type.
source§

impl<'a, T, D: Device, S: Shape> From<(Buffer<'a, T, D, S>, (usize, usize))> for Matrix<'a, T, D, S>

source§

fn from((data, dims): (Buffer<'a, T, D, S>, (usize, usize))) -> Self

Converts to this type from the input type.
source§

impl<'a, T, D: Device, S: Shape> From<(Buffer<'a, T, D, S>, usize, usize)> for Matrix<'a, T, D, S>

source§

fn from((data, rows, cols): (Buffer<'a, T, D, S>, usize, usize)) -> Self

Converts to this type from the input type.
source§

impl<'a, T: Clone> From<(usize, usize, &[T])> for Matrix<'a, T>

source§

fn from((rows, cols, slice): (usize, usize, &[T])) -> Self

Converts to this type from the input type.
source§

impl<'a, T: Clone, const N: usize> From<(usize, usize, [T; N])> for Matrix<'a, T>

source§

fn from((rows, cols, slice): (usize, usize, [T; N])) -> Self

Converts to this type from the input type.
source§

impl<'a, T, D, S: Shape> Mul<&Matrix<'a, T, D, S>> for &Matrix<'a, T, D, S>where D: BaseOps<T, S>,

§

type Output = Matrix<'a, T, D, S>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<'a, T, D, S: Shape> Mul<&Matrix<'a, T, D, S>> for Matrix<'a, T, D, S>where D: BaseOps<T, S>,

§

type Output = Matrix<'a, T, D, S>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<'a, T: Copy, S: Shape, D: AdditionalOps<T, S>> Mul<&T> for Matrix<'a, T, D, S>

§

type Output = Matrix<'a, T, D, S>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<'a, T, D, S: Shape> Mul<Matrix<'a, T, D, S>> for Matrix<'a, T, D, S>where D: BaseOps<T, S>,

§

type Output = Matrix<'a, T, D, S>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<'a, T, S: Shape, D: AdditionalOps<T, S>> Mul<T> for &Matrix<'a, T, D, S>

§

type Output = Matrix<'a, T, D, S>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<'a, T, S: Shape, D: AdditionalOps<T, S>> Mul<T> for Matrix<'a, T, D, S>

§

type Output = Matrix<'a, T, D, S>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<T, D, S: Shape> MulAssign<&Matrix<'_, T, D, S>> for Matrix<'_, T, D, S>where D: AssignOps<T, S, D>,

source§

fn mul_assign(&mut self, rhs: &Self)

Performs the *= operation. Read more
source§

impl<T, D, S: Shape> MulAssign<Matrix<'_, T, D, S>> for Matrix<'_, T, D, S>where D: AssignOps<T, S, D>,

source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
source§

impl<T, S, D> MulAssign<T> for Matrix<'_, T, D, S>where S: Shape, D: ScalarAssign<T, S>,

source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
source§

impl<'a, T, D, S> Sub<&Matrix<'a, T, D, S>> for &Matrix<'a, T, D, S>where D: BaseOps<T, S>, S: Shape,

§

type Output = Matrix<'a, T, D, S>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<'a, T, D, S> Sub<&Matrix<'a, T, D, S>> for Matrix<'a, T, D, S>where D: BaseOps<T, S>, S: Shape,

§

type Output = Matrix<'a, T, D, S>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<'a, T, D, S> Sub<Matrix<'a, T, D, S>> for &Matrix<'a, T, D, S>where D: BaseOps<T, S>, S: Shape,

§

type Output = Matrix<'a, T, D, S>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Matrix<'_, T, D, S>) -> Self::Output

Performs the - operation. Read more
source§

impl<'a, T, D, S> Sub<Matrix<'a, T, D, S>> for Matrix<'a, T, D, S>where D: BaseOps<T, S>, S: Shape,

§

type Output = Matrix<'a, T, D, S>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<'a, T, D, S> Sub<T> for &Matrix<'a, T, D, S>where S: Shape, D: AdditionalOps<T, S>,

§

type Output = Matrix<'a, T, D, S>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<'a, T> Sub<T> for Matrix<'a, T>

§

type Output = Matrix<'a, T, CPU, ()>

The resulting type after applying the - operator.
source§

fn sub(self, _rhs: T) -> Self::Output

Performs the - operation. Read more
source§

impl<T, D, S: Shape> SubAssign<&Matrix<'_, T, D, S>> for &mut Matrix<'_, T, D, S>where D: AssignOps<T, S, D>,

source§

fn sub_assign(&mut self, rhs: &Matrix<'_, T, D, S>)

Performs the -= operation. Read more
source§

impl<T, D, S: Shape> SubAssign<&Matrix<'_, T, D, S>> for Matrix<'_, T, D, S>where D: AssignOps<T, S, D>,

source§

fn sub_assign(&mut self, rhs: &Self)

Performs the -= operation. Read more
source§

impl<T, D, S: Shape> SubAssign<Matrix<'_, T, D, S>> for &mut Matrix<'_, T, D, S>where D: AssignOps<T, S, D>,

source§

fn sub_assign(&mut self, rhs: Matrix<'_, T, D, S>)

Performs the -= operation. Read more
source§

impl<T, D, S: Shape> SubAssign<Matrix<'_, T, D, S>> for Matrix<'_, T, D, S>where D: AssignOps<T, S, D>,

source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
source§

impl<'a, T, D, C, const B: usize, const A: usize> WithShape<&'a D, C> for Matrix<'a, T, D, Dim2<B, A>>where D: Device, Buffer<'a, T, D, Dim2<B, A>>: WithShape<&'a D, C>,

source§

fn with(device: &'a D, array: C) -> Self

Auto Trait Implementations§

§

impl<'a, T, D, S> RefUnwindSafe for Matrix<'a, T, D, S>where D: RefUnwindSafe, <D as Device>::Ptr<T, S>: RefUnwindSafe,

§

impl<'a, T, D, S> Send for Matrix<'a, T, D, S>

§

impl<'a, T, D, S> Sync for Matrix<'a, T, D, S>

§

impl<'a, T, D, S> Unpin for Matrix<'a, T, D, S>where <D as Device>::Ptr<T, S>: Unpin,

§

impl<'a, T, D, S> UnwindSafe for Matrix<'a, T, D, S>where D: RefUnwindSafe, <D as Device>::Ptr<T, S>: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere T: Clone,

§

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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.