MAOS
Multithreaded Adaptive Optics Simulator
recon_utils.h File Reference

Functions

void apply_L2 (dcell **xout, const dspcell *L2, const dcell *xin, real alpha)
 
void apply_invpsd (dcell **xout, const void *extra, const dcell *xin, real alpha, int xb, int yb)
 
void apply_fractal (dcell **xout, const void *extra, const dcell *xin, real alpha, int xb, int yb)
 
void TTFR (dcell *x, const dcell *TTF, const dcell *PTTF)
 
void applyW (dcell *xin, const dsp *W0, const dmat *W1, const real *wt)
 
dcellcalcWmcc (const dcell *A, const dcell *B, const dsp *W0, const dmat *W1, const dmat *wt)
 
void TomoR (dcell **xout, const void *A, const dcell *xin, const real alpha)
 
void TomoRt (dcell **gout, const void *A, const dcell *xin, const real alpha)
 
void TomoL (dcell **xout, const void *A, const dcell *xin, const real alpha)
 
void FitL (dcell **xout, const void *A, const dcell *xin, const real alpha)
 
void FitR (dcell **xout, const void *A, const dcell *xin, const real alpha)
 
dspnea2sp (dmat *nea, int ll, int ur, int ng)
 
void nea_chol (dmat **pout, const dmat *in, int ng)
 
void nea_inv (dmat **pout, const dmat *in, int ng, real scale)
 
void nea_mm (dmat **pout, const dmat *in, int ng)
 
void nea_check (dmat *nea, int nsa, int ng)
 
void psfr_calc (sim_t *simu, dcell *opdr, dcell *dmpsol, dcell *dmerr, dcell *dmerr_lo)
 
void shift_grad (sim_t *simu)
 
lmatloc_coord2ind (loc_t *aloc, dmat *dead)
 
cn2est_tcn2est_prepare (const parms_t *parms, const powfs_t *powfs)
 
void cn2est_isim (dcell *cn2res, recon_t *recon, const parms_t *parms, const dcell *grad, int *tomo_update)
 

Detailed Description

Reusable utilities for wavefront reconstruction and DM fitting, supporting recon.c

Function Documentation

◆ apply_L2()

void apply_L2 ( dcell **  xout,
const dspcell L2,
const dcell xin,
real  alpha 
)

Apply Laplacian2 to xin and accumulates to xout.

◆ apply_invpsd()

void apply_invpsd ( dcell **  xout,
const void *  A,
const dcell xin,
real  alpha,
int  xb,
int  yb 
)

Apply turbulence invpsd to xin in Fourier space, scaled by alpha and add to xout. do nothing if xb != yb, since we apply to diagonal only. if xb==-1, do all blocks.

Todo:
: this is not thread safe.

◆ apply_fractal()

void apply_fractal ( dcell **  xout,
const void *  A,
const dcell xin,
real  alpha,
int  xb,
int  yb 
)

Apply fractal regularization to x, scaled by alpha. do nothing if xb != yb, since we apply to diagonal only. if xb==-1, do all blocks.

Todo:
: this is not thread safe.

◆ TTFR()

void TTFR ( dcell x,
const dcell TTF,
const dcell PTTF 
)

Removing Tip/Tilt/Focus from LGS grads. TTF is the Tip/tilt/focus modes, and PTTF is the pseudo inverse of it, weighted by subaperture noise. It is not diagonal if differential focus is removed. So cannot be in Tomo_nea

◆ applyW()

void applyW ( dcell xin,
const dsp W0,
const dmat W1,
const real *  wt 
)

apply weighting W0/W1 with weighting wt for each block. W0*xin-W1*(W1'*xin);

◆ calcWmcc()

dcell* calcWmcc ( const dcell A,
const dcell B,
const dsp W0,
const dmat W1,
const dmat wt 
)

Compute W0/W1 weighted dot product: \(A^T(W0 B-W1 (W1^T B))\)

◆ TomoR()

void TomoR ( dcell **  xout,
const void *  A,
const dcell gin,
const real  alpha 
)

Apply tomography right hand operator without using assembled matrix. Fast and saves memory. The operation is the same as the Tomo_nea and Tomo_iprop in TomoL, so merge the implemenations.

xout=HXW'GP'*NEAI(1-TTF*PTTF)*gin.

◆ TomoRt()

void TomoRt ( dcell **  gout,
const void *  A,
const dcell xin,
const real  alpha 
)

Transpose operation of TomoRt. From xout -> gin

◆ TomoL()

void TomoL ( dcell **  xout,
const void *  A,
const dcell xin,
const real  alpha 
)

Apply tomography left hand side operator without using assembled matrix. Fast and saves memory. Only useful in CG. Accumulates to xout;

Some timing information: Generated in T410s with Intel Core i5 520 M @ 2.4 GHz (1 T is 1 thread, 2 T is 2 thread) and Poweredge with dual Xeon X5355 2.66Ghz (1 P is 1 thread, 8 P is 8 thread) Time 1 T 2 T 1 P 8 P HXW: 7.8 5.4 7.7 5.0 GP: 4.3 2.6 3.6 1.4 TTFR: 0.3 0.3 0.4 0.6 neai: 0.5 0.3 0.5 0.4 GP': 3.2 2.1 3.4 1.0 HXW': 5.5 4.7 7.4 4.9 cxx: 3.2 2.5 3.5 2.7

◆ FitL()

void FitL ( dcell **  xout,
const void *  A,
const dcell xin,
const real  alpha 
)

Apply fit left hand side matrix in CG mode without using assembled matrix. Slow. don't use. Assembled matrix is faster because of multiple directions.

◆ FitR()

void FitR ( dcell **  xout,
const void *  A,
const dcell xin,
const real  alpha 
)

Apply fit right hand side matrix in CG mode without using assembled matrix. Slow. don't use. Assembled matrix is faster because of multiple directions.

◆ nea2sp()

dsp* nea2sp ( dmat nea,
int  ll,
int  ur,
int  ng 
)

Convert column vector nsax2 or nsax3 to sparse matrix. The third column of nea is coupling. ll: controls lower left ur: controls upper right if ng>2, treat as diagonal matrix (for raw PWFS)

◆ nea_chol()

void nea_chol ( dmat **  pout,
const dmat in,
const int  ng 
)

Apply cholesky in a 2x2 symmetric matrix packed in [a[0,0],a[1,1],a[0,1]] as row vector. Input and output may be the same. if ng>2, treat as diagonal matrix

◆ nea_inv()

void nea_inv ( dmat **  pout,
const dmat in,
int  ng,
real  scale 
)

Apply matrix inversion in a 2x2 symmetrisa matrix packed in row vector [a[0,0],a[1,1],a[0,1]] Input and output may be the same.

◆ nea_mm()

void nea_mm ( dmat **  pout,
const dmat in,
const int  ng 
)

Apply LL' to lower diagonal matrix packed in [a[0,0],a[1,1],a[0,1]] as row vector. Input and output may be the same. if ng>2, treat as diagonal matrix

◆ nea_check()

void nea_check ( dmat nea,
int  nsa,
int  ng 
)

Check the dimension of NEA and fix if possible

◆ psfr_calc()

void psfr_calc ( sim_t simu,
dcell opdr,
dcell dmpsol,
dcell dmerr,
dcell dmerr_lo 
)

Compute and save PSF reconstruction telemetry. For pseudo open loop estimations, like high order loop, we add opdr to, and subtract dmpsol from the OPD. For closed loop estimations, like ahst low order or lsr, we add dmerr_lo, and dmerr to the OPD.

◆ shift_grad()

void shift_grad ( sim_t simu)

Shift gradient when new gradients are ready (in the end of parallel section in sim in CL or wfsgrad in OL). Do not execute in parallel with other routines. In GLAO mode, also averaged gradients from the same type of powfs.

◆ loc_coord2ind()

lmat* loc_coord2ind ( loc_t aloc,
dmat dead 
)

Parse the input dead actuator location to actuator indices based on aloc. 2015-03-30: build a mask for dead actuators based on coordinate.

Parameters
[in]alocAloc
[in]deadFile containing dead actuators

◆ cn2est_prepare()

cn2est_t* cn2est_prepare ( const parms_t parms,
const powfs_t powfs 
)

Prepare arrays for cn2 estimation. Multiple pairs can be used to do Cn2 Estimation. The result will be an average of them.

◆ cn2est_isim()

void cn2est_isim ( dcell cn2res,
recon_t recon,
const parms_t parms,
const dcell grad,
int *  tomo_update 
)

Wrapper of Cn2 Estimation operations in recon.c