Trait totsu::linalg::LinAlgEx [−][src]
pub trait LinAlgEx<F: Float>: LinAlg<F> + Clone { fn transform_ge(
transpose: bool,
n_row: usize,
n_col: usize,
alpha: F,
mat: &[F],
x: &[F],
beta: F,
y: &mut [F]
); fn transform_sp(
n: usize,
alpha: F,
mat: &[F],
x: &[F],
beta: F,
y: &mut [F]
); fn proj_psd_worklen(sn: usize) -> usize; fn proj_psd(x: &mut [F], eps_zero: F, work: &mut [F]); fn sqrt_spmat_worklen(n: usize) -> usize; fn sqrt_spmat(mat: &mut [F], eps_zero: F, work: &mut [F]); }
Expand description
Linear algebra extended subtrait
Required methods
Calculate \(\alpha G x + \beta y\).
- If
transpose
istrue
, Calculate \(\alpha G^T x + \beta y\) instead. alpha
is a scalar \(\alpha\).n_row
is a number of rows of \(G\).n_col
is a number of columns of \(G\).mat
is a matrix \(G\), stored in column-major. The length ofmat
shall ben_row * n_col
.x
is a vector \(x\). The length ofx
shall ben_col
(orn_row
iftranspose
istrue
).beta
is a scalar \(\beta\).y
is a vector \(y\) before entry, \(\alpha G x + \beta y\) (or \(\alpha G^T x + \beta y\) iftranspose
istrue
) on exit. The length ofy
shall ben_row
(orn_col
iftranspose
istrue
).
Calculate \(\alpha S x + \beta y\), where \(S\) is a symmetric matrix, supplied in packed form.
n
is a number of rows and columns of \(S\).alpha
is a scalar \(\alpha\).mat
is a matrix \(S\), stored in packed form (the upper-triangular part in column-wise). The length ofmat
shall ben * (n + 1) / 2
.x
is a vector \(x\). The length ofx
shall ben
.beta
is a scalar \(\beta\).y
is a vector \(y\) before entry, \(\alpha S x + \beta y\) on exit. The length ofy
shall ben
.
fn proj_psd_worklen(sn: usize) -> usize
fn proj_psd_worklen(sn: usize) -> usize
Query of a length of work slice that LinAlgEx::proj_psd
requires.
Returns a length of work slice.
sn
is a number of variables, that is a length ofx
ofLinAlgEx::proj_psd
.
Euclidean projection \(x\) onto \({\rm vec}(\mathcal{S}_+^k)\).
x
is \(x\), a vector to be projected before entry, and shall be replaced with the projected vector on exit. The length ofx
shall be \(\frac12k(k+1)\)eps_zero
shall be the same value ascrate::solver::SolverParam::eps_zero
.work
slice is used for temporal variables.
fn sqrt_spmat_worklen(n: usize) -> usize
fn sqrt_spmat_worklen(n: usize) -> usize
Query of a length of work slice that LinAlgEx::sqrt_spmat
requires.
Returns a length of work slice.
n
is a number of rows and columns of \(S\) (seeLinAlgEx::sqrt_spmat
).
fn sqrt_spmat(mat: &mut [F], eps_zero: F, work: &mut [F])
fn sqrt_spmat(mat: &mut [F], eps_zero: F, work: &mut [F])
Calculate \(S^{\frac12}\), where \(S \in \mathcal{S}_+^n\), supplied in packed form.
mat
is a matrix \(S\) before entry, \(S^{\frac12}\) on exit. It shall be stored in packed form (the upper-triangular part in column-wise). The length ofmat
shall be \(\frac12n(n+1)\).eps_zero
should be the same value ascrate::solver::SolverParam::eps_zero
.work
slice is used for temporal variables.