ChunkedQuantizedMatrix

Struct ChunkedQuantizedMatrix 

Source
pub struct ChunkedQuantizedMatrix<F> { /* private fields */ }
Expand description

A memory-mapped quantized matrix that operates on chunks of data to avoid loading the entire matrix into memory at once

Implementations§

Source§

impl<F> ChunkedQuantizedMatrix<F>

Source

pub fn new( matrix: &ArrayView2<'_, F>, bits: u8, method: QuantizationMethod, file_path: &str, ) -> LinalgResult<Self>

Create a new chunked quantized matrix from an explicit matrix

Quantizes the matrix and stores it to disk in chunks to support out-of-core processing.

§Arguments
  • matrix - Matrix to quantize (will be processed in chunks)
  • bits - Bit width for quantization
  • method - Quantization method
  • file_path - Path to store the quantized data
§Returns

A new ChunkedQuantizedMatrix instance

Source

pub fn symmetric(self) -> Self

Mark the operator as symmetric

§Returns

Self with the symmetric flag set to true

Source

pub fn positive_definite(self) -> Self

Mark the operator as positive definite

§Returns

Self with the positive_definite flag set to true

Source

pub fn params(&self) -> &QuantizationParams

Get the quantization parameters

Source

pub fn apply(&self, x: &ArrayView1<'_, F>) -> LinalgResult<Array1<F>>

Apply the matrix to a vector

This method loads the matrix from disk in chunks and applies each chunk to the input vector, accumulating the results to avoid loading the entire matrix into memory at once.

§Arguments
  • x - Input vector
§Returns

Result vector

Source

pub fn tomatrix_free_op(&self) -> LinalgResult<QuantizedMatrixFreeOp<F>>

Convert to a regular QuantizedMatrixFreeOp

This loads the entire matrix into memory, so it should only be used for matrices that can fit in memory.

§Returns

A QuantizedMatrixFreeOp instance

Source

pub fn solve_conjugate_gradient( &self, b: &Array1<F>, max_iter: usize, tol: F, adaptive_precision: bool, ) -> LinalgResult<Array1<F>>

Solve a linear system using out-of-core conjugate gradient

§Arguments
  • b - Right-hand side vector
  • max_iter - Maximum number of iterations
  • tol - Convergence tolerance
  • adaptive_precision - Whether to adaptively adjust precision during iterations
§Returns

Solution vector

Source

pub fn from_file(filepath: &str) -> LinalgResult<Self>

Create a new chunked quantized matrix from an existing file

This loads the metadata from an existing quantized matrix file but doesn’t load the entire matrix into memory.

§Arguments
  • file_path - Path to the quantized matrix file
§Returns

A new ChunkedQuantizedMatrix instance

Trait Implementations§

Source§

impl<F> MatrixFreeOp<F> for ChunkedQuantizedMatrix<F>

Source§

fn apply(&self, x: &ArrayView1<'_, F>) -> LinalgResult<Array1<F>>

Apply the linear operator to a vector
Source§

fn nrows(&self) -> usize

Get the number of rows in the linear operator
Source§

fn ncols(&self) -> usize

Get the number of columns in the linear operator
Source§

fn is_symmetric(&self) -> bool

Check if the linear operator is symmetric
Source§

fn is_positive_definite(&self) -> bool

Check if the linear operator is positive definite

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V