pub struct CscMatrix { /* private fields */ }Expand description
列圧縮形式(CSC: Compressed Sparse Column)の疎行列
非ゼロ要素を列単位で格納する疎行列フォーマット。 列ポインタ・行インデックス・値の3配列で表現される。
§フォーマット詳細
列 j の非ゼロ要素は values[col_ptr[j]..col_ptr[j+1]] に格納され、
対応する行インデックスは row_ind[col_ptr[j]..col_ptr[j+1]] に入る。
各列の行インデックスは昇順にソートされている。
Implementations§
Source§impl CscMatrix
impl CscMatrix
pub fn nnz(&self) -> usize
pub fn col_ptr(&self) -> &[usize]
pub fn row_ind(&self) -> &[usize]
pub fn values(&self) -> &[f64]
Sourcepub fn scale_values(&self, factor: f64) -> Self
pub fn scale_values(&self, factor: f64) -> Self
Returns a new matrix with all non-zero values multiplied by factor.
pub fn nrows(&self) -> usize
pub fn ncols(&self) -> usize
Sourcepub fn row_infinity_norms(&self) -> Vec<f64>
pub fn row_infinity_norms(&self) -> Vec<f64>
各行の∞ノルム(行ごとの最大絶対値)を一括計算する: O(nnz)
CSC格式では行方向アクセスが非効率だが、全非ゼロ要素を1回走査して 各行の最大絶対値を収集することで O(nnz) で完了する。
Sourcepub fn from_triplets(
rows: &[usize],
cols: &[usize],
vals: &[f64],
nrows: usize,
ncols: usize,
) -> Result<Self, SolverError>
pub fn from_triplets( rows: &[usize], cols: &[usize], vals: &[f64], nrows: usize, ncols: usize, ) -> Result<Self, SolverError>
Builds a CSC matrix from COO triplets.
Duplicate (row, col) entries are summed; results with |v| ≤ DROP_TOL are dropped.
Sourcepub fn transpose(&self) -> Self
pub fn transpose(&self) -> Self
転置行列を生成する(新しい CSC 行列として返す)
元の行列の行と列を入れ替えた行列を返す。 counting sort を使用するため O(nnz) の計算量となる。
Sourcepub fn mat_vec_mul(&self, x: &[f64]) -> Result<Vec<f64>, SolverError>
pub fn mat_vec_mul(&self, x: &[f64]) -> Result<Vec<f64>, SolverError>
Matrix-vector product y = A * x. O(nnz).
Sourcepub fn get_column(&self, j: usize) -> Result<(&[usize], &[f64]), SolverError>
pub fn get_column(&self, j: usize) -> Result<(&[usize], &[f64]), SolverError>
Returns (row_indices, values) slices for column j; both are sorted by row index.
pub fn identity(n: usize) -> Self
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CscMatrix
impl RefUnwindSafe for CscMatrix
impl Send for CscMatrix
impl Sync for CscMatrix
impl Unpin for CscMatrix
impl UnsafeUnpin for CscMatrix
impl UnwindSafe for CscMatrix
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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