MAOS
Multithreaded Adaptive Optics Simulator
muv.h File Reference

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)
 

Detailed Description

Decomposes a matrix into sparse and low rank terms and do math operations.


Data Structure Documentation

◆ muv_t

struct muv_t

Decompose an operator into a sparse operator and optional low rank terms. M-U*V'; M is usually symmetrical.

+ Collaboration diagram for muv_t:
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 Documentation

◆ exfun_t

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.

Function Documentation

◆ muv()

void muv ( dcell **  xout,
const void *  A_,
const dcell xin,
const real  alpha 
)

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.

◆ muv_trans()

void muv_trans ( dcell **  xout,
const void *  A_,
const dcell xin,
const real  alpha 
)

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.

◆ muv_ib()

void muv_ib ( dcell **  xout,
const void *  B,
const dcell xin,
const real  alpha 
)

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.

◆ muv_direct_solve()

void muv_direct_solve ( dcell **  xout,
const muv_t A,
dcell xin 
)

convert the data from dcell to dmat and apply muv_direct_solve() . May be done in place.

◆ muv_direct_solve_mat()

void muv_direct_solve_mat ( dmat **  xout,
const muv_t A,
dmat xin 
)

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.

◆ muv_direct_prep()

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}] \]

◆ muv_direct_free()

void muv_direct_free ( muv_t A)

Free cholesky decompositions or SVD.

◆ muv_direct_diag_solve()

void muv_direct_diag_solve ( dmat **  xout,
const muv_t A,
dmat xin,
int  ib 
)

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.

◆ muv_bgs_solve()

void muv_bgs_solve ( dcell **  px,
const muv_t A,
const dcell b 
)

solve A*x=b using the Block Gauss Seidel algorithm. The matrix is always assembled. We use routines from muv. to do the computation.

Parameters
[in,out]pxThe output vector. input for warm restart.
[in]AContain info about the The left hand side matrix A
[in]bThe right hand side vector to solve

◆ muv_solve()

real muv_solve ( dcell **  px,
const muv_t L,
const muv_t R,
dcell b 
)

solve x=A^-1*B*b using algorithms depend on algorithm, wrapper.

Parameters
[in,out]pxThe output vector. input for warm restart.
[in]LContain info about the left hand side matrix A
[in]RContain info about the right hand side matrix B
[in]bThe right hand side vector to solve. null is special case

◆ muv_direct_spsolve()

void* muv_direct_spsolve ( const muv_t A,
const dsp xin 
)

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.

◆ muv_direct_diag_prep()

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.

◆ muv_direct_diag_free()

void muv_direct_diag_free ( muv_t A)

Free cholesky decompositions or SVD.

◆ muv_free()

void muv_free ( muv_t A)

Free muv_t struct