MatrixGetEntry

Trait MatrixGetEntry 

Source
pub trait MatrixGetEntry<T>
where Self: MatrixDimensions + Sized, T: Clone,
{ // Required method unsafe fn get_entry_unchecked(&self, row: i64, column: i64) -> T; // Provided methods fn get_entry( &self, row: impl TryInto<i64> + Display, column: impl TryInto<i64> + Display, ) -> Result<T, MathError> { ... } fn get_entries(&self) -> Vec<Vec<T>> { ... } fn get_entries_rowwise(&self) -> Vec<T> { ... } fn get_entries_columnwise(&self) -> Vec<T> { ... } }
Expand description

Is implemented by matrices to get entries.

Required Methods§

Source

unsafe fn get_entry_unchecked(&self, row: i64, column: i64) -> T

Returns the value of a specific matrix entry without performing any checks, e.g. checking whether the entry is part of the matrix.

Parameters:

  • row: specifies the row in which the entry is located.
  • column: specifies the column in which the entry is located.
§Safety

To use this function safely, make sure that the selected entry is part of the matrix. If it is not, memory leaks, unexpected panics, etc. might occur.

Provided Methods§

Source

fn get_entry( &self, row: impl TryInto<i64> + Display, column: impl TryInto<i64> + Display, ) -> Result<T, MathError>

Returns the value of a specific matrix entry.

Parameters:

  • row: specifies the row in which the entry is located.
  • column: specifies the column in which the entry is located.

Negative indices can be used to index from the back, e.g., -1 for the last element.

Errors can occur if the provided indices are not within the dimensions of the provided matrices, the bases of the matrix and value are not compatible, e.g. different modulus.

§Errors and Failures
Source

fn get_entries(&self) -> Vec<Vec<T>>

Outputs a Vec<Vec<T>> containing all entries of the matrix s.t. any entry in row i and column j can be accessed via entries[i][j] if entries = matrix.get_entries.

§Examples
use qfall_math::{integer::{MatZ, Z}, traits::*};
let matrix = MatZ::sample_uniform(3, 3, 0, 16).unwrap();

let entries = matrix.get_entries();
let mut added_entries = Z::default();
for row in entries {
    for entry in row {
        added_entries += entry;
    }
}
Source

fn get_entries_rowwise(&self) -> Vec<T>

Outputs a Vec<T> containing all entries of the matrix in a row-wise order, i.e. a matrix [[2, 3, 4],[5, 6, 7]] can be accessed via this function in this order [2, 3, 4, 5, 6, 7].

§Examples
use qfall_math::{integer::{MatZ, Z}, traits::*};
let matrix = MatZ::sample_uniform(3, 3, 0, 16).unwrap();

let entries = matrix.get_entries_rowwise();
let mut added_entries = Z::default();
for entry in entries {
    added_entries += entry;
}
Source

fn get_entries_columnwise(&self) -> Vec<T>

Outputs a Vec<T> containing all entries of the matrix in a column-wise order, i.e. a matrix [[2, 3, 4],[5, 6, 7]] can be accessed via this function in this order [2, 5, 3, 6, 4, 7].

§Examples
use qfall_math::{integer::{MatZ, Z}, traits::*};
let matrix = MatZ::sample_uniform(3, 3, 0, 16).unwrap();

let entries = matrix.get_entries_columnwise();
let mut added_entries = Z::default();
for entry in entries {
    added_entries += entry;
}

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§