![]() |
MAOS
Multithreaded Adaptive Optics Simulator
|
Data Structures | |
| struct | muv_t |
Typedefs | |
| typedef void(* | exfun_t) (dcell **xout, const void *A, const dcell *xin, const real alpha, int xb, int yb) |
Functions | |
| void | muv (dcell **xout, const void *A, const dcell *xin, const real alpha) |
| void | muv_trans (dcell **xout, const void *A, const dcell *xin, const real alpha) |
| void | muv_ib (dcell **xout, const void *A, const dcell *xin, const real alpha) |
| void | muv_direct_solve (dcell **xout, const muv_t *A, dcell *xin) |
| void | muv_direct_solve_mat (dmat **xout, const muv_t *A, dmat *xin) |
| void | muv_direct_prep (muv_t *muv, real svd) |
| void | muv_direct_free (muv_t *muv) |
| void | muv_direct_diag_solve (dmat **xout, const muv_t *A, dmat *xin, int ib) |
| void | muv_bgs_solve (dcell **px, const muv_t *A, const dcell *b) |
| real | muv_solve (dcell **px, const muv_t *L, const muv_t *R, dcell *b) |
| void * | muv_direct_spsolve (const muv_t *A, const dsp *xin) |
| void | muv_direct_diag_prep (muv_t *muv, real svd) |
| void | muv_direct_diag_free (muv_t *muv) |
| void | muv_free (muv_t *A) |
Decomposes a matrix into sparse and low rank terms and do math operations.
| struct muv_t |
Decompose an operator into a sparse operator and optional low rank terms. M-U*V'; M is usually symmetrical.
| Data Fields | ||
|---|---|---|
| cell * | M |
block sparse matrix or dense matrix |
| dcell * | U |
low rank terms U |
| dcell * | V |
low rank terms V |
| exfun_t | exfun |
Optionally attach an extra function that applies extra data |
| void * | extra |
Data used by fun to apply: (*exfun)(y,extra,x,alpha) to compute |
| spchol * | C |
Cholesky factor. |
| dmat * | Up |
\(M^{-1}U\) |
| dmat * | Vp |
\(M^{-1}[V*(I-Up'*V)^{-1}]\) |
| dmat * | MI |
Inverse of M via svd |
| dcell * | MIB |
Inverse of each diagonal element of M via svd |
| spchol ** | CB |
Cholesky factor of each diagonal element of M |
| dcell * | UpB |
Up for each diagonal component |
| dcell * | VpB |
Vp for each diagonal component |
| int | nb |
Number of blocks in CB; |
| cgfun_t | Mfun |
Do M*x with a function |
| cgfun_t | Mtfun |
Do M'*x with a function |
| void * | Mdata |
Parameter to Mfun |
| prefun_t | pfun |
The preconditioner function |
| void * | pdata |
The precondtioner data |
| int | alg |
The algorithm: 0: CBS, 1: CG, 2: SVD |
| int | bgs |
Whether use BGS (Block Gauss Seidel) method, and how many iterations |
| int | warm |
Whether use warm restart |
| int | maxit |
How many iterations |
| typedef void(* exfun_t) (dcell **xout, const void *A, const dcell *xin, const real alpha, int xb, int yb) |
Avoid function casting. It will hide data safety check and hide bugs.
Decomposes a matrix into sparse and low rank terms and do math operations.
The forward operations can be represented by a matrix M and two low rank terms as y = ( M - u*v' ) *x , or by a function Mfun and corresponding argument Mdata.
This can also be used to solve linear equations using muv_solve() or muv_bgs_solve(). Apply the sparse plus low rank compuation to xin with scaling of alpha: \(xout=(A.M-A.U*A.V')*xin*alpha\); U,V are low rank.
| [in,out] | xout | The output, accumulated into. Allocated if NULL. |
| [in] | A_ | The muv_t operator. Declared void for use as a pcg callback. |
| [in] | xin | The input vector. |
| [in] | alpha | Scaling factor. |
Apply the transpose of operation muv(); Apply the sparse plug low rand compuation to xin with scaling of alpha: \(xout=(A.M-A.V*A.U')*xin*alpha\); U,V are low rank.
| [in,out] | xout | The output, accumulated into. Allocated if NULL. |
| [in] | A_ | The muv_t operator. Declared void for use as a pcg callback. |
| [in] | xin | The input vector. Nothing is done if NULL and A->M is set. |
| [in] | alpha | Scaling factor. |
Apply the sparse plus low rand compuation to xin with scaling of alpha for block (xb, yb): \(xout_x=(A.M_xy-A.U_xi*A.V_yi')*xin_y*alpha\); U,V are low rank.
| [in,out] | xout | The output, block xb is accumulated into. Allocated if NULL. |
| [in] | B | Pointer to MUV_IB_T containing the muv_t operator and block indices. If xb or yb is -1, the full muv() is applied. |
| [in] | xin | The input vector (one column). |
| [in] | alpha | Scaling factor. |
convert the data from dcell to dmat and apply muv_direct_solve_mat(). May be done in place.
| [out] | xout | The output. Allocated if NULL. |
| [in] | A | The muv_t struct prepared by muv_direct_prep(). |
| [in] | xin | The input. Nothing is done if NULL. |
Apply CBS or SVD multiply to xin to get xout. Create xout is not exist already. xout = A^-1 * xin; xin and xout can be the same for in place operation.
| [out] | xout | The output. Allocated if NULL. Can be the same as xin. |
| [in] | A | The muv_t struct prepared by muv_direct_prep(). |
| [in] | xin | The input. |
| void muv_direct_prep | ( | muv_t * | A, |
| real | svd ) |
Cholesky factorization (svd=0) or svd (svd>0) on the sparse matrix and its low rank terms. if svd is less than 1, it is also used as the threshold in SVD inversion.
When there are low rank terms,
\[ Up=M^{-1}*U, Vp=-M^{-1}*[V*(I-Up'*V)^{-1}] \]
| [in,out] | A | The muv_t struct. The factorization (C or MI, Up, Vp) is stored into it. With svd, U and V are absorbed into MI and freed. |
| [in] | svd | 0: Cholesky factorization. Otherwise use SVD; if |svd|<1 it is the SVD inversion threshold. |
| void muv_direct_free | ( | muv_t * | A | ) |
Free cholesky decompositions or SVD.
| [in,out] | A | The muv_t struct whose C, MI, Up, Vp are freed. |
Apply cholesky backsubstitution solve to xin to get xout. Create xout is not exist already. xin and xout can be the same for in place operation.
| [out] | xout | The output. Allocated if NULL. Can be the same as xin. |
| [in] | A | The muv_t struct prepared by muv_direct_diag_prep(). |
| [in] | xin | The input. Nothing is done if NULL. |
| [in] | ib | The diagonal block index. |
solve A*x=b using the Block Gauss Seidel algorithm. The matrix is always assembled. We use routines from muv. to do the computation.
| [in,out] | px | The output vector. Input for warm restart. Allocated if NULL. |
| [in] | A | Contain info about the left hand side matrix A. |
| [in] | b | The right hand side vector to solve. Nothing is done if NULL. |
solve x=A^-1*B*b using algorithms depend on algorithm, wrapper.
| [in,out] | px | The output vector. Input for warm restart. Allocated if NULL. |
| [in] | L | Contain info about the left hand side matrix A. |
| [in] | R | Contain info about the right hand side matrix B. If NULL, b is used as the right hand side directly. |
| [in] | b | The right hand side vector to solve. NULL is special case. |
Apply CBS or SVD multiply to square sparse matrix. xout = A^-1 * xin * (A^-1)^T. The output is dmat if using SVD, and dsp if using CBS.
| [in] | A | The muv_t struct prepared by muv_direct_prep(). |
| [in] | xin | The square sparse input matrix. |
| void muv_direct_diag_prep | ( | muv_t * | A, |
| real | svd ) |
Cholesky factorization (svd=0) or svd (svd>0) on each diagonal element of the block sparse matrix and its low rank terms. if svd is less than 1, it is also used as the threshold in SVD inversion.
When there are low rank terms,
\[ Up=M^{-1}U, Vp=-M^{-1}[V*(I-Up'*V)^{-1}] \]
For each diagonal block.
| [in,out] | A | The muv_t struct. The factorization (CB or MIB, UpB, VpB) is stored into it. U and V are reduced to column block vectors. |
| [in] | svd | 0: Cholesky factorization. Otherwise use SVD; if svd<1 it is the SVD inversion threshold. |
| void muv_direct_diag_free | ( | muv_t * | A | ) |
Free cholesky decompositions or SVD of the diagonal blocks.
| [in,out] | A | The muv_t struct whose CB, MIB, UpB, VpB are freed. |