MAOS
Multithreaded Adaptive Optics Simulator
Loading...
Searching...
No Matches
cmath.h File Reference

Macros

#define AOS_LIB_TYPE
 
#define AOS_CMAT(A)   c##A
 
#define AOS_DMAT(A)   d##A
 

Typedefs

typedef comp(* cminsearch_fun) (const comp *x, void *info)
 

Functions

cmatcnew (long nx, long ny)
 
cmatcnew_file (long nx, long ny, const char *keywords, const char *format,...)
 
cmatcnew_do (long nx, long ny, comp *p, mem_t *mem)
 
cmatcmat_cast (const_anyarray A)
 
int cinit (cmat **A, long nx, long ny)
 
void cfree_content (cmat *A)
 
void cfree_do (cmat *A)
 
cmatcref (const cmat *in)
 
cmatcref_reshape (const cmat *in, long nx, long ny)
 
cmatcrefcols (const cmat *in, long icol, long ncol)
 
void ccols (cmat *out, const cmat *in, long icol, long ncol)
 
int cresize (cmat *A, long nx, long ny)
 
cmatcsub (const cmat *in, long sx, long nx, long sy, long ny)
 
cmatccat (const cmat *in1, const cmat *in2, int dim)
 
cmatcdup (const cmat *in)
 
void czero (cmat *A)
 
int czerocol (cmat *A, int icol)
 
uint32_t chash (const cmat *A, uint32_t key)
 
void ccp (cmat **out0, const cmat *in)
 
cmatctrans (const cmat *A)
 
void cset (cmat *A, const comp val)
 
void cshow (const cmat *A, const char *format,...)
 
void cshow_diag (const cmat *A, const char *format,...)
 
void cvecperm (cmat *out, const cmat *in, const long *perm)
 
void cvecpermi (cmat *out, const cmat *in, const long *perm)
 
int cflip (cmat *A, int axis)
 
comp cvecsum (const comp *__restrict p, long np)
 
comp csum (const cmat *A)
 
void cnormalize_sum (cmat *A, comp sum)
 normalize the sum of A to sum.
 
void cnormalize_sumabs (cmat *A, real sum)
 normalize the sum of abs(A) to sum.
 
comp cmean (const cmat *A)
 
comp ctrace (const cmat *A)
 
void csort (cmat *A, int ascend)
 
void cvecmaxmin (const comp *__restrict p, long N, real *max, real *min)
 
comp cvecdot (const comp *__restrict p1, const comp *__restrict p2, const real *__restrict p3, long n)
 
void cvecnormalize_sum (comp *__restrict p, long nloc, comp norm)
 
void cvecnormalize_sumabs (comp *__restrict p, long nloc, comp norm)
 
real cvecmaxabs (const comp *__restrict p, long n)
 
void cmaxmin (const cmat *A, real *max, real *min)
 
real cmax (const cmat *A)
 
real cmaxabs (const cmat *A)
 
real cmin (const cmat *A)
 
real csumabs (const cmat *in)
 
real csumsq (const cmat *in)
 
real csumdiffsq (const cmat *A, const cmat *B)
 
cmatcunique (const cmat *input, int ascend)
 
void cfftshift (cmat *A)
 
int ccpcorner2center (cmat *A, const cmat *B)
 
int cshift (cmat **B0, const cmat *A, int sx, int sy)
 
ccellccell_cast (const cell *A)
 
ccellccellnew2 (const ccell *A)
 
ccellccellnew3 (long nx, long ny, long *nnx, long *nny)
 
ccellccellnew_same (long nx, long ny, long mx, long my)
 
ccellccellnew_file (long nx, long ny, long *nnx, long *nny, const char *keywords, const char *format,...)
 
ccellccellnewsame_file (long nx, long ny, long mx, long my, const char *keywords, const char *format,...)
 
void ccellzero (ccell *dc)
 
void ccellset (ccell *dc, comp alpha)
 
ccellccelltrans (const ccell *A)
 
ccellccellref (const ccell *in)
 
ccellccelldup (const ccell *in)
 
void ccellcp (ccell **out0, const ccell *in)
 
ccellccellreduce (const ccell *A, int dim)
 
ccellccellcat (const ccell *A, const ccell *B, int dim)
 
void ccellcat2 (ccell **A, const ccell *B, int dim)
 
ccellccellcat_each (const ccell *A, const ccell *B, int dim)
 
ccellc2cellref (const cmat *A, long *dims, long ndim)
 
void c2cell (ccell **B, const cmat *A, const ccell *ref)
 
cmatccell_col (ccell *input, long icol)
 
comp ccellsum (const ccell *A)
 
cmatccellsum_each (const ccell *A)
 
int cisnan (const cmat *A)
 
real cnorm (const cmat *in)
 
real cstd (const cmat *in)
 
void crandu (cmat *A, const comp mean, rand_t *rstat)
 
void crandn (cmat *A, const comp sigma, rand_t *rstat)
 
void cscale (cmat *A, real w)
 
comp cdot (const cmat *A, const cmat *B)
 
comp cwdot (const comp *a, const cmat *w, const comp *b)
 
void ccwm (cmat *A, const cmat *B)
 
void ccwm2 (cmat *A, const cmat *B1, real wt1, const cmat *B2, real wt2)
 
void ccwm3 (cmat *__restrict A, const cmat *__restrict W, const cmat *__restrict B1, const real wt1, const cmat *__restrict B2, const real wt2)
 
void ccwmcol (cmat *__restrict A, const cmat *__restrict B)
 
void ccwmrow (cmat *__restrict A, const cmat *__restrict B)
 
void ccwdiv (cmat *B, const cmat *A, comp value)
 
void cmulvec (comp *__restrict y, const cmat *__restrict A, const comp *__restrict x, const comp alpha)
 
void cmm (cmat **C0, const comp beta, const cmat *A, const cmat *B, const char trans[2], const comp alpha)
 
void cmm3 (cmat **pout, comp beta, const cmat *A, const cmat *B, const cmat *C, const char trans[4], comp alpha)
 Compute 3 matrix multipliation: out=out*alpha+beta*op(A)*op(B)*op(C)
 
void cinvspd_inplace (cmat *A)
 
cmatcinvspd (const cmat *A)
 
void cinv_inplace (cmat *A)
 
cmatcinv (const cmat *A)
 
cmatcchol (const cmat *A)
 
cmatcmcc (const cmat *A, const cmat *wt)
 
cmatcimcc (const cmat *A, const cmat *wt)
 
cmatctmcc (const cmat *A, const cmat *wt)
 
cmatcpinv2 (const cmat *A, const_anyarray W, real thres1, real thres2)
 
cmatcpinv (const cmat *A, const_anyarray W)
 Wrap dpinv2 with default parameters.
 
comp cdiff (const cmat *A, const cmat *B)
 
int ccircle (cmat *A, real cx, real cy, real dx, real dy, real r, comp val)
 
int crectangle (cmat *A, real cx, real cy, real rx, real ry, real theta, comp val)
 
void crotvec (cmat *A, const real theta)
 
void crotvect (cmat *A, const real theta)
 
void crotvecnn (cmat **B0, const cmat *A, real theta)
 
void cmulvec3 (comp *y, const cmat *A, const comp *x)
 
void ccorr (cmat **corr, const cmat *A, const cmat *B)
 
void cpara3 (real *grad, const cmat *corr)
 
void ccog (real *grad, const cmat *i0, real offsetx, real offsety, real thres, real bkgrnd, real flux)
 
void cshift2center (cmat *A, real offsetx, real offsety)
 
int cclip (cmat *A, real min, real max)
 
void cgramschmidt (cmat *Mod, real *amp)
 
void cmuldiag (cmat *A, const dmat *s)
 
void ccwpow (cmat *A, real power)
 
void ccwexp (cmat *A, real alpha)
 
void ccwpow_thres (cmat *A, real power, real thres)
 
void csvd (cmat **U, dmat **Sdiag, cmat **VT, const cmat *A)
 
void csvd_cache (cmat **U, dmat **Sdiag, cmat **VT, const cmat *A)
 
void csvd_pow2 (cmat *A, real power, real thres1, real thres2)
 
void csvd_pow (cmat *A, real power)
 Wrap svd_pow with default parameters.
 
void cexpm (cmat **out, real alpha, const cmat *A, real beta)
 
void cpolyval (cmat *A, dmat *p)
 
void caddI (cmat *A, comp val)
 
void cadd (cmat **B0, comp bc, const cmat *A, const comp ac)
 
void cadd_relax (cmat **B0, comp bc, const cmat *A, const comp ac)
 
void caddcol (cmat *B, long icol, comp bc, const cmat *A, const comp ac)
 
void cadds (cmat *A, const comp ac)
 
cmatclogspace (real emin, real emax, long n)
 
cmatclinspace (real min, real dx, long n)
 
cmatcinterp1 (const cmat *xin, const cmat *yin, const cmat *xnew, comp y0)
 
cmatcinterp1_2 (const cmat *xyin, const cmat *xnew)
 
cmatcinterp1linear (const cmat *xin, const cmat *yin, const cmat *xnew, comp y0)
 
cmatcinterp1log (const cmat *xin, const cmat *yin, const cmat *xnew, comp y0)
 
void cblend (cmat *__restrict A, cmat *__restrict B, int overlap)
 
void chistfill (cmat **out, const cmat *A, real center, real spacing, int n)
 
cmatcspline_prep (cmat *x, cmat *y)
 
cmatcspline_eval (cmat *coeff, cmat *x, cmat *xnew)
 
cmatcspline (cmat *x, cmat *y, cmat *xnew)
 
void ccwlog10 (cmat *A)
 
void ccwlog (cmat *A)
 
void cembed (cmat *__restrict A, const cmat *__restrict B, const real theta)
 
void cembedd (cmat *__restrict A, const dmat *__restrict B, const real theta)
 
real cfwhm (cmat *A)
 
void cgauss_fit (real *mr, real *ma, real *mb, real *theta, cmat *A, real thres)
 
real cgauss_width (cmat *A, real thres)
 
real cfwhm_gauss (cmat *A)
 
cmatcenc (const cmat *A, const cmat *dvec, int type, int nthread)
 
int cminsearch (comp *x, int nmod, comp ftol, int nmax, cminsearch_fun fun, void *info)
 
void cbessik (comp x, comp xnu, comp *ri, comp *rk, comp *rip, comp *rkp)
 
comp ctrapz (const cmat *x, const cmat *y)
 
real ccellnorm (const ccell *in)
 
void ccellscale (anyarray A, real w)
 
void ccelldropempty (ccell **A0, int dim)
 
comp ccelldot (const ccell *A, const ccell *B)
 
void ccellcwm (ccell *B, const ccell *A)
 
ccellccellinvspd (ccell *A)
 
ccellccellinv (ccell *A)
 
ccellccellinvspd_each (ccell *A)
 
ccellccellpinv2 (const ccell *A, const_anyarray W, real thres1, real thres2)
 
ccellccellpinv (const ccell *A, const_anyarray W)
 Wrap cellpinv2 with default parameters.
 
void ccellsvd_pow2 (ccell *A, real power, real thres1, real thres2)
 
void ccellsvd_pow (ccell *A, real power)
 wrap cellsvd_pow2.
 
void ccellcwpow (ccell *A, real power)
 
void ccelldropzero (ccell *B, real thres)
 
real ccelldiff (const ccell *A, const ccell *B)
 
int ccellclip (ccell *Ac, real min, real max)
 
ccellccellsub (const ccell *in, long sx, long nx, long sy, long ny)
 
ccellcbspline_prep (cmat *x, cmat *y, cmat *z)
 
cmatcbspline_eval (ccell *coeff, cmat *x, cmat *y, cmat *xnew, cmat *ynew)
 
void cmaprot (anyarray A_, real theta)
 
void ccwmc (cmat *__restrict A, const cmat *__restrict B)
 
void ccwmd (cmat *__restrict A, const dmat *__restrict B)
 
void cembed_wvf (cmat *__restrict A, const real *opd, const real *amp, const int nopdx, const int nopdy, const real wvl, const real theta)
 
void cembedc_flag (cmat *__restrict A, const cmat *__restrict B, const real theta, CEMBED flag)
 
void ccpcorner (cmat *A, const cmat *__restrict B, CEMBED flag)
 
void cabstoreal (cmat *A)
 
void cabs2toreal (cmat *A, real scale)
 
void ccpd (cmat **__restrict A, const dmat *__restrict B)
 
void creal2d (dmat **__restrict A0, real alpha, const cmat *__restrict B, real beta)
 
void cimag2d (dmat **__restrict A0, real alpha, const cmat *__restrict B, real beta)
 
void cabs22d (dmat **__restrict A0, real alpha, const cmat *__restrict B, real beta)
 
void carg2d (dmat **__restrict A0, real alpha, const cmat *__restrict B, real beta)
 
void ctilt2 (cmat *otf, cmat *otfin, real sx, real sy, int peak_corner)
 
void ctilt (cmat *otf, real sx, real sy, int peak_corner)
 
void ccogreal (real *grad, const cmat *i0, real offsetx, real offsety, real thres, real bkgrnd)
 
void ccogabs (real *grad, const cmat *i0, real offsetx, real offsety, real thres, real bkgrnd)
 
void cwritedata (file_t *fp, const cmat *A, long ncol)
 
cmatcreaddata (file_t *fp, header_t *header)
 
cmatcnew_mmap (long nx, long ny, const char *keywords, const char *format,...)
 
ccellccellnew_mmap (long nx, long ny, long *nnx, long *nny, const char *keywords, const char *format,...)
 
ccellccellnewsame_mmap (long nx, long ny, long mx, long my, const char *keywords, const char *format,...)
 
cmatcread_mmap (const char *format,...)
 
ccellccellread_mmap (const char *format,...)
 
cspcspnew (long nx, long ny, long nzmax)
 
cspcspref (const csp *A)
 
cspcspdup (const csp *A)
 
cspcspnew2 (const csp *A)
 
cspcspnewrandu (long nx, long ny, const comp mean, real fill, rand_t *rstat)
 
void cspsetnzmax (csp *sp, long nzmax)
 
cspcsp_cast (const cell *A)
 
void cspfree_do (csp *sp)
 
void cspdisp (const csp *sp)
 
int cspcheck (const csp *sp)
 
void cspscale (csp *A, const comp beta)
 
void cspscalex (csp *A, const cmat *xs)
 
void cspscaley (csp *A, const cmat *ys)
 
cspcellcspcellref (const cspcell *in)
 
cspcellcspcell_cast (const cell *A)
 
void cspcellscale (cspcell *A, const comp beta)
 
cspcspnewdiag (long N, comp *vec, comp alpha)
 
cmatcspdiag (const csp *A)
 
void cspmuldiag (csp *__restrict A, const comp *w, comp alpha)
 
void cspmv (cmat *y, const csp *A, const cmat *__restrict x, char trans, comp alpha)
 
void cspmulcreal (comp *__restrict y, const csp *A, const comp *__restrict x, real alpha)
 
void cspmm (cmat **yout, const csp *A, const cmat *x, const char trans[2], const comp alpha)
 
void cmulsp (cmat **yout, const cmat *x, const csp *A, const char trans[2], const comp alpha)
 
comp cspwdot (const cmat *y, const csp *A, const cmat *x)
 
comp cspcellwdot (const ccell *y, const cspcell *A, const ccell *x)
 
void ccellmm (panyarray C0, const_anyarray A, const_anyarray B, const char trans[2], const real alpha)
 
ccellccellmm2 (const ccell *A, const ccell *B, const char trans[2])
 
cspc2sp (cmat *A, real thres)
 
void cspfull (cmat **out0, const csp *A, const char trans, const comp alpha)
 
void cspcellfull (ccell **out0, const cspcell *A, const char trans, const comp alpha)
 
cspcspadd2 (const csp *A, comp a, const csp *B, comp b)
 
void cspadd (csp **A0, comp alpha, const csp *B, comp beta)
 
void ccelladd (panyarray pA, real ac, const_anyarray B, real bc)
 
cspcspaddI (const csp *A0, comp alpha)
 
void ccelladdI (anyarray A, comp alpha)
 
cspcsptrans (const csp *A)
 
void cspconj (csp *)
 
cspcspmulsp (const csp *A, const csp *B, const char trans[2])
 
void cspmulsp2 (csp **C0, const csp *A, const csp *B, const char trans[2], const comp scale)
 
cspcellcspcelltrans (const cspcell *spc)
 
cspcspcat (const csp *A, const csp *B, int type)
 
cspcspcell2sp (const cspcell *A)
 
cmatcspsum (const csp *A, int col)
 
cmatcspsumabs (const csp *A, int col)
 
real csptrace (const csp *A, real power)
 Compute the sum of diagonal items (trace) with power.
 
void cspclean (csp *A)
 
void cspdroptol (csp *A, real thres)
 
void cspcelldroptol (cspcell *A, real thres)
 
lmatcspdropemptycol (csp *A)
 
void cspsort (csp *A)
 
void cspcellsort (cspcell *A)
 
void cspsym (csp **A)
 
void cspcellsym (cspcell **A)
 
cspcspconvolvop (cmat *A)
 
cspcspperm (csp *A, int reverse, long *pcol, long *prow)
 
cspcspinvbdiag (const csp *A, long bs)
 
ccellcspblockextract (const csp *A, long bs)
 
cmatccell2m (const_anyarray A)
 
void cspwritedata (file_t *fp, const csp *sp)
 
cspcspreaddata (file_t *fp, header_t *header)
 
void cfft_free_plan (struct fft_t *fft)
 
void cfft2 (cmat *A, int dir)
 
void cfft2i (cmat *A, int dir)
 
void cfft2s (cmat *A, int dir)
 
void cfft2partial (cmat *A, int ncomp, int dir)
 
cmatcffttreat (cmat *A)
 
void dfft_free_plan (struct fft_t *fft)
 
void dcell_fft2 (dcell *dc, int dir)
 
void dfft1plan_r2hc (dmat *out, int dir)
 
void dfft1 (dmat *A, int dir)
 

Function Documentation

◆ cnew()

cmat * cnew ( long  nx,
long  ny 
)

Create a new CX(mat). Initialized to zero.

Create a new ZX(mat). Initialized to zero.

◆ cnew_file()

cmat * cnew_file ( long  nx,
long  ny,
const char *  keywords,
const char *  format,
  ... 
)

Calls CX(new) with a filename to be saved to.

Calls ZX(new) with a filename to be saved to.

◆ cmat_cast()

cmat * cmat_cast ( const_anyarray  A)

check and cast an object to matrix

◆ cinit()

int cinit ( cmat **  A,
long  nx,
long  ny 
)

check the size of matrix if exist. Otherwise create it. content is not zeroed if already exists.

  • empty matrix is initialized.
  • existing matrix is not resized.

◆ cfree_content()

void cfree_content ( cmat A)

free content of a matrix object.

◆ cfree_do()

void cfree_do ( cmat A)

free a matrix object.

◆ cref()

cmat * cref ( const cmat in)

creat a reference to an existing matrix. header is duplicated if exists.

◆ cref_reshape()

cmat * cref_reshape ( const cmat in,
long  nx,
long  ny 
)

create an new reference another with different shape.

  • total number of elements must be preserved
  • set ny to 1 or 0 to return a vector.

◆ crefcols()

cmat * crefcols ( const cmat in,
long  icol,
long  ncol 
)

creat a new matrix referencing columns in existing matrix. reference counted.

◆ ccols()

void ccols ( cmat out,
const cmat in,
long  icol,
long  ncol 
)

Override a stack matrix struct with pointers to columns of another matrix. Does not add reference count the original data.

◆ cresize()

int cresize ( cmat A,
long  nx,
long  ny 
)

Resize a matrix by adding or removing columns or rows. Data is kept whenever possible.

  • -1 in dimension preserves original value.
  • 0 in dimension will free array.

◆ csub()

cmat * csub ( const cmat in,
long  sx,
long  nx,
long  sy,
long  ny 
)

Create a new sub matrix of nx*ny starting from(sx,sy) and copy the data.

◆ ccat()

cmat * ccat ( const cmat in1,
const cmat in2,
int  dim 
)

Concatenate two matrixes into 1 along "dim" (1 for x, 2 for y)

◆ cdup()

cmat * cdup ( const cmat in)

duplicate a matrix

◆ czero()

void czero ( cmat A)

Set elements to zero.

◆ czerocol()

int czerocol ( cmat A,
int  icol 
)

Set column elements to zero.

◆ chash()

uint32_t chash ( const cmat A,
uint32_t  key 
)

Compute the hashlittle

◆ ccp()

void ccp ( cmat **  out0,
const cmat in 
)

copy the values from one matrix to another.

◆ ctrans()

cmat * ctrans ( const cmat A)

transpose a matrix

◆ cset()

void cset ( cmat A,
const dcomplex  val 
)

set values of each element in an matrix to val.

◆ cshow()

void cshow ( const cmat A,
const char *  format,
  ... 
)

display a matrix.

◆ cshow_diag()

void cshow_diag ( const cmat A,
const char *  format,
  ... 
)

display diagonal of a matrix.

◆ cvecperm()

void cvecperm ( cmat out,
const cmat in,
const long perm 
)

Permute the vector so that out(:)=in(p);

◆ cvecpermi()

void cvecpermi ( cmat out,
const cmat in,
const long perm 
)

Reverse permute the vector so that out(p)=in(:);

◆ cflip()

int cflip ( cmat A,
int  axis 
)

Flip the matrix along the set axis. 0 to flip both, 1 along x, 2 along y.

◆ csum()

comp csum ( const cmat A)

Calculate sum of all the elements in A.

◆ cmean()

comp cmean ( const cmat A)

Calculate average of all the elements in A.

◆ ctrace()

comp ctrace ( const cmat A)

compute the trace (sum of diagonal elements)

◆ cmaxmin()

void cmaxmin ( const cmat A,
double *  max,
double *  min 
)

find the maximum and minimum value

◆ cmax()

real cmax ( const cmat A)

find the maximum value

◆ cmaxabs()

real cmaxabs ( const cmat A)

find the maximum of abs of all elements

◆ cmin()

real cmin ( const cmat A)

find the minimum value

◆ csumabs()

real csumabs ( const cmat A)

compute the sum of abs of all elements

◆ csumsq()

real csumsq ( const cmat A)

compute the sum of A.*A

◆ csumdiffsq()

real csumdiffsq ( const cmat A,
const cmat B 
)

compute the sum of (A-B)^2

◆ cfftshift()

void cfftshift ( cmat A)

shift frequency components by n/2

◆ ccpcorner2center()

int ccpcorner2center ( cmat A,
const cmat B 
)

reorder B and embed/crop into center of A .

4 * * 3
* * * *
* * * *
2 * * 1

to

1 2
3 4

◆ cshift()

int cshift ( cmat **  B0,
const cmat A,
int  sx,
int  sy 
)

cyclic shift A by nx and ny to B.

4   3     1   2

2   1 to  3   4

◆ ccell_cast()

ccell * ccell_cast ( const cell A)

cast a cell object to actual cell after checking.

◆ ccellnew2()

ccell * ccellnew2 ( const ccell A)

create an new cell similar to A in shape. When a cell is empty, it is created with an emtry matrix and cannot be overriden.

◆ ccellnew3()

ccell * ccellnew3 ( long  nx,
long  ny,
long nnx,
long nny 
)

Create an new cell with matrix specified. Each block is stored continuously in memory.

◆ ccellnew_same()

ccell * ccellnew_same ( long  nx,
long  ny,
long  mx,
long  my 
)

Create an new cell with matrix specified. Each block is stored continuously in memory.

◆ ccellnew_file()

ccell * ccellnew_file ( long  nx,
long  ny,
long nnx,
long nny,
const char *  keywords,
const char *  format,
  ... 
)

Calls cellnew3 with a filename to be saved to.

◆ ccellnewsame_file()

ccell * ccellnewsame_file ( long  nx,
long  ny,
long  mx,
long  my,
const char *  keywords,
const char *  format,
  ... 
)

Calls cellnew_same with a filename to be saved to.

◆ ccellzero()

void ccellzero ( ccell dc)

Setting all elements of a cell to zero.

◆ ccellset()

void ccellset ( ccell dc,
dcomplex  val 
)

setting all elements of a cell to alpha.

◆ ccelltrans()

ccell * ccelltrans ( const ccell A)

transpose a cell object

◆ ccellref()

ccell * ccellref ( const ccell in)

creat a cell reference an existing cell by referencing the elements.

◆ ccelldup()

ccell * ccelldup ( const ccell in)

duplicate a CX(cell) object. Not implemented for lmat or imat as CX(cellcp) is defined in spmm.c

duplicate a ZX(cell) object. Not implemented for lmat or imat as ZX(cellcp) is defined in spmm.c

◆ ccellcp()

void ccellcp ( ccell **  A_,
const ccell B_ 
)

Copy B to A.

Takes parameters of matrix, sparse matrix, or cell array of them.

◆ ccellreduce()

ccell * ccellreduce ( const ccell A,
int  dim 
)

reduce nx*ny cell matrix to 1*ny if dim=1 and nx*1 if dim=2 by merging the cells.

◆ ccellcat()

ccell * ccellcat ( const ccell A,
const ccell B,
int  dim 
)

concatenate two cell matrices along dimenstion 'dim'.

◆ ccellcat2()

void ccellcat2 ( ccell **  pA,
const ccell B,
int  dim 
)

concatenate two cell matrices along dimenstion 'dim'.

◆ ccellcat_each()

ccell * ccellcat_each ( const ccell A,
const ccell B,
int  dim 
)

concatenate coresponding elements of each CX(cell). They must have the same shape.

concatenate coresponding elements of each ZX(cell). They must have the same shape.

◆ c2cellref()

ccell * c2cellref ( const cmat A,
long dims,
long  ndim 
)

convert a vector to cell using dimensions specified in dims. Reference the vector

◆ c2cell()

void c2cell ( ccell **  B,
const cmat A,
const ccell ref 
)

make A a cell array using shape information from ref if *B is NULL.

Notice that empty cells may be replaced by zeros if it is within valid column or row.

◆ ccell_col()

cmat * ccell_col ( ccell input,
long  icol 
)

input is nsa*ncol cell. each cell has npix=nx*ny elements. Extract icol of cell as npix*nsa array.

◆ ccellsum()

comp ccellsum ( const ccell A)

create sum of all the elements in A.

◆ ccellsum_each()

cmat * ccellsum_each ( const ccell A)

return sum of each cell in a CX(mat)

return sum of each cell in a ZX(mat)

◆ cisnan()

int cisnan ( const cmat A)

Check for NaN in elements

◆ cnorm()

real cnorm ( const cmat A)

compute the norm(2) of A

◆ cstd()

real cstd ( const cmat A)

compute the standard deviation of A

◆ crandu()

void crandu ( cmat A,
const dcomplex  max,
rand_t rstat 
)

Fill A with random uniform numbers between [0, 1]*max

◆ crandn()

void crandn ( cmat A,
const dcomplex  sigma,
rand_t rstat 
)

Fill A with random normal distribution numbers with standard deviation of sigma.

◆ cscale()

void cscale ( cmat A,
double  w 
)

scale each element of A by w.

◆ cdot()

comp cdot ( const cmat A,
const cmat B 
)

compute the dot product of A and B. (inner product)

◆ cwdot()

comp cwdot ( const dcomplex *  a,
const cmat w,
const dcomplex *  b 
)

compute weighted dot product a'*(w*b)

◆ ccwmcol()

void ccwmcol ( cmat *__restrict  A,
const cmat *__restrict  B 
)

Compute component wise multiply A=A.*(B1*wt1+B2*wt2) component-wise multiply of three matrices. A=A.*W.*(B1*wt1+B2*wt2) Component-wise multiply each column of A with B A(:,i)=A(:,i).*B;

◆ ccwmrow()

void ccwmrow ( cmat *__restrict  A,
const cmat *__restrict  B 
)

component-wise multiply of columns of A with combination of B1 and B2: A(:,i)=A(:,i)*(B1*wt1+B2*wt2); component wise multiply of 2d complex matrix A,W and 1d vector B. A(:,i)=A(:,i).*W(:,i).*B; Component wise multiply each row of A with B. A(i,:)=A(i,:)*B

◆ ccwdiv()

void ccwdiv ( cmat B,
const cmat A,
dcomplex  value 
)

component-wise multiply of rows of A with combination of B1 and B2: A(i,:)=A(i,:).*(B1*wt1+B2*wt2); Component wise division B=B./A. 0/0 is replace by 'value';

◆ cmulvec()

void cmulvec ( dcomplex *__restrict  y,
const cmat *__restrict  A,
const dcomplex *__restrict  x,
const dcomplex  alpha 
)

multiply a CX(mat) matrix with a vector and accumulate to y: y+=A*x*alpha

multiply a ZX(mat) matrix with a vector and accumulate to y: y+=A*x*alpha

◆ cmm()

void cmm ( cmat **  C0,
const dcomplex  beta,
const cmat A,
const cmat B,
const char  trans[2],
const dcomplex  alpha 
)

compute matrix product using blas dgemm.; C=beta*C+ alpha *trans(A)*trans(B); if C exist.

◆ cinvspd_inplace()

void cinvspd_inplace ( cmat A)

inplace invert a small square SPD matrix using lapack dposv_, usually (A'*w*A). by solving Ax=I; copy x to A. dposv_ modifies A also. be careful

◆ cinvspd()

cmat * cinvspd ( const cmat A)

out of place version of dinvspd_inplace

◆ cinv_inplace()

void cinv_inplace ( cmat A)

inplace invert a general square matrix using lapack dgesv_

◆ cinv()

cmat * cinv ( const cmat A)

out of place version of dinv

◆ cchol()

cmat * cchol ( const cmat A)

Compute the cholesky decomposition of a symmetric semi-definit dense matrix.

◆ cmcc()

cmat * cmcc ( const cmat A,
const cmat wt 
)

compute (A'*W*A); where diag(W)=wt

◆ cimcc()

cmat * cimcc ( const cmat A,
const cmat wt 
)

compute inv(dmcc(A, wt))

◆ ctmcc()

cmat * ctmcc ( const cmat A,
const cmat wt 
)

compute (A*W*A'); where diag(W)=wt

◆ cpinv2()

cmat * cpinv2 ( const cmat A,
const_anyarray  W_,
double  thres1,
double  thres2 
)

compute the pseudo inverse of matrix A with weigthing of full matrix W or sparse matrix weighting Wsp. For full matrix, wt can be either W or diag (W) for diagonal weighting. B=inv(A'*W*A+tikcr)*A'*W; thres is the threshold to truncate eigenvalues.

◆ cdiff()

comp cdiff ( const cmat A,
const cmat B 
)

compute the relative difference betwee two vectors. sqrt(||A-B||/||A||) using norm2. for debugging purpose.

◆ ccircle()

int ccircle ( cmat A,
double  cx,
double  cy,
double  dx,
double  dy,
double  r,
dcomplex  val 
)

Generate a new gray pixel map based on bilinear influence functions used in mkw. It creates slightly larger map than an filled circle to account for the sampling effect. The Center and Radius cx,cy,r are in unit of meter, The sampling dx,dy specify spacing of the points in meter along x or y dimension. Each full point received value of 'val'

◆ crectangle()

int crectangle ( cmat A,
double  cx,
double  cy,
double  rx,
double  ry,
double  theta,
dcomplex  val 
)

Generate a new gray pixel map based on bilinear influence functions used in mkw. It creates slightly larger map than an filled rectangle to account for the sampling effect. The Center and half width cx,cy,rx,ry are in unit of meter, The sampling dx,dy specify spacing of the points in meter along x or y dimension. Each full point received value of 'val'

◆ crotvec()

void crotvec ( cmat A,
const double  theta 
)

rotate the column vectors CCW, equivalent as rotate coordinate theta CW. A is nx2 while A(:,1) is x, A(:,2) is y.

◆ crotvect()

void crotvect ( cmat A,
const double  theta 
)

rotate the row vectors CCW. same as rotate coordinate theta CW. A is 2xn A(:,1) is x, A(:,2) is y.

◆ crotvecnn()

void crotvecnn ( cmat **  B0,
const cmat A,
double  theta 
)

rotate a 2x2 covariance matrix A by theta CCW (coordinate rotate -theta CCW) or from ra to xy coordinate. R*A*R';

◆ cmulvec3()

void cmulvec3 ( dcomplex *  y,
const cmat A,
const dcomplex *  x 
)

T matrix vector multiply optimized for just three values. y=A*x;

◆ ccorr()

void ccorr ( cmat **  pout,
const cmat A,
const cmat B 
)

Compute the correlation matrix.

◆ cpara3()

void cpara3 ( double *  grad,
const cmat corr 
)

Compute the parabolic fit center using 3x3 points around the peak.

◆ ccog()

void ccog ( double *  grad,
const cmat im,
double  offsetx,
double  offsety,
double  thres,
double  bkgrnd,
double  flux 
)

Compute thresholded center of gravity. The threshold is absolute value. bkgrnd is removed from i0 when computing cog. offset is the offset of the reference point (cog=0) from the physical center. all length are given in terms of pixel.

◆ cshift2center()

void cshift2center ( cmat A,
double  offsetx,
double  offsety 
)

Shift the image in A to center on physical center+[offsetx,offsety] using cog and fft.

◆ ccwpow()

void ccwpow ( cmat A,
double  power 
)

Raise all elements to power 'power'

◆ ccwexp()

void ccwexp ( cmat A,
double  alpha 
)

compute exponential of all elements after scaling by alpha

◆ csvd()

void csvd ( cmat **  U,
dmat **  Sdiag,
cmat **  VT,
const cmat A 
)

Compute SVD of a general matrix A. A=U*diag(S)*V'; diag(S) is returned.

◆ csvd_cache()

void csvd_cache ( cmat **  U,
dmat **  Sdiag,
cmat **  VT,
const cmat A 
)

Compute SVD with caching.

◆ csvd_pow2()

void csvd_pow2 ( cmat A,
double  power,
double  thres1,
double  thres2 
)

computes pow(A,power) in place using svd. positive thres: Drop eigenvalues that are smaller than thres * max eigen value negative thres: Drop eigenvalues that are smaller than thres * previous eigen value (sorted descendantly).

Parameters
A[in/out] The matrix
[in]powerpower of eigen values. usually -1 for inverse
[in]thres1SVD inverse absolute threshold
[in]thres2SVD inverse relative threshold

◆ cexpm()

void cexpm ( cmat **  out,
double  alpha,
const cmat A,
double  beta 
)

computes out=out*alpha+exp(A*beta) using scaling and squaring method. Larger scaling is more accurate but slower. Tested against matlab expm

First, scaling the matrix by 2^-n times so it is smaller than 1/threshold. Then compute exp(A*beta*2^-n) using Tylor expansion. Then compute the final answer by taking exponential of 2^n.

◆ cpolyval()

void cpolyval ( cmat A,
dmat p 
)

Compute polynomial functional value inplace

◆ cadd()

void cadd ( cmat **  B0,
dcomplex  bc,
const cmat A,
const dcomplex  ac 
)

compute B=bc*B+ac*A behavior changed on 2009-11-02. if A is NULL, don't do anything.

◆ cadd_relax()

void cadd_relax ( cmat **  B0,
dcomplex  bc,
const cmat A,
const dcomplex  ac 
)

compute B=bc*B+ac*A. Use smallest dimension of both. behavior changed on 2009-11-02. if A is NULL, don't do anything.

◆ caddcol()

void caddcol ( cmat B,
long  icol,
dcomplex  bc,
const cmat A,
const dcomplex  ac 
)

Compute B[:,icol]=bc*B[:,icol]+ac*A where A is vector.

◆ clogspace()

cmat * clogspace ( double  emin,
double  emax,
long  n 
)

Create log spaced vector.

◆ clinspace()

cmat * clinspace ( double  min,
double  dx,
long  n 
)

Create linearly spaced vector.

◆ ccwlog10()

void ccwlog10 ( cmat A)

Do a component wise log10 on each element of A.

◆ ccwlog()

void ccwlog ( cmat A)

Do a component wise log10 on each element of A.

◆ cembed()

void cembed ( cmat *__restrict  out,
const cmat *__restrict  in,
const double  theta 
)

Embed a ninx*niny matrix in into A with optional rotation by theta CCW (output points are rotated by theta -CCW) around the fft center. Used to rotate the PSF from x-y to radial-azimuthal coordinate in radial format CCD. A may be bigger or smaller than B.

◆ cembedd()

void cembedd ( cmat *__restrict  out,
const dmat *__restrict  in,
const double  theta 
)

embed a ninx*niny matrix in into A with optional rotation by -theta CCW (coordinate rotate theta CCW) around the fft center. Used to rotate the PSF from x-y to radial-azimuthal coordinate in radial format CCD. A may be bigger or smaller than B.

◆ cfwhm()

real cfwhm ( cmat A)

Calculate number of pixels having values larger than or equal to half of maximum and convert to diameter.

For more accurate calculation of Gaussian beams, use the sqrt(2*log(2))*CX(gauss_width).

Calculate number of pixels having values larger than or equal to half of maximum and convert to diameter.

For more accurate calculation of Gaussian beams, use the sqrt(2*log(2))*ZX(gauss_width).

◆ cgauss_fit()

void cgauss_fit ( double *  mr,
double *  ma,
double *  mb,
double *  angle,
cmat A,
double  thres 
)

Calculate D4s width of Gaussian 2D function

Parameters
mrEquivalent radius of the same area
mamajor axis
mbminor axi
angleangle
AThe irradiance (intensity)
thresThe threshold relative to peak.

◆ cgauss_width()

real cgauss_width ( cmat A,
double  thres 
)

A convenient wrapper

◆ cfwhm_gauss()

real cfwhm_gauss ( cmat A)

Use gauss fit to compute fwhm

◆ cminsearch()

int cminsearch ( dcomplex *  x,
int  nmod,
dcomplex  ftol,
int  nmax,
cminsearch_fun  fun,
void info 
)

Search minimum along multiple dimenstions. scale contains the scale of each dimension. x contains initial warm restart values.

◆ cbessik()

void cbessik ( dcomplex  x,
dcomplex  xnu,
dcomplex *  ri,
dcomplex *  rk,
dcomplex *  rip,
dcomplex *  rkp 
)

Returns the modified Bessel functions ri = Iν , rk = Kν and their derivatives rip = Iν , rkp = Kν, for positive x and for xnu = ν ≥ 0.

◆ ccellnorm()

real ccellnorm ( const ccell A)

compute norm2.

◆ ccellscale()

void ccellscale ( anyarray  A_,
double  w 
)

scale each element of A.

◆ ccelldropempty()

void ccelldropempty ( ccell **  A0,
int  dim 
)

drop empty rows or columns. size of *A0 is changed.

◆ ccelldot()

comp ccelldot ( const ccell A,
const ccell B 
)

Compute the dot produce of two dcell.

◆ ccellcwm()

void ccellcwm ( ccell B,
const ccell A 
)

Component wise multiply of two dcell B=A.*B*alpha

◆ ccellinvspd()

ccell * ccellinvspd ( ccell A)

Inplace Invert a SPD matrix. It is treated as a block matrix

◆ ccellinv()

ccell * ccellinv ( ccell A)

Inplace Invert a matrix. It is treated as a block matrix.

◆ ccellinvspd_each()

ccell * ccellinvspd_each ( ccell A)

invert each component of the dcell. Each cell is treated as an individual matrix.

◆ ccellpinv2()

ccell * ccellpinv2 ( const ccell A,
const_anyarray  W_,
double  thres1,
double  thres2 
)

compute the pseudo inverse of block matrix A. A is n*p cell, wt n*n cell or sparse cell. \(B=inv(A'*W*A)*A'*W\)

Parameters
[in]AThe matrix to pseudo invert
[in]W_The weighting matrix. dense or sparse
[in]thres1SVD absolute inverse threshold
[in]thres2SVD relative inverse threshold

◆ ccellsvd_pow2()

void ccellsvd_pow2 ( ccell A,
double  power,
double  thres1,
double  thres2 
)

compute the power of a block matrix using svd method. First convert it do CX(mat), do the power, and convert back to block matrix.

compute the power of a block matrix using svd method. First convert it do ZX(mat), do the power, and convert back to block matrix.

◆ ccellcwpow()

void ccellcwpow ( ccell A,
double  power 
)

raise each cell in the cell array to power of power.

◆ ccelldropzero()

void ccelldropzero ( ccell B,
double  thres 
)

drop empty blocks (zero). Size of B is not modified.

◆ ccelldiff()

real ccelldiff ( const ccell A,
const ccell B 
)

compute ||A-B||/||A|| use mean.

◆ ccellclip()

int ccellclip ( ccell Ac,
double  min,
double  max 
)

clip a CX(cell) array to max at 'max', min at 'min'

clip a ZX(cell) array to max at 'max', min at 'min'

◆ ccellsub()

ccell * ccellsub ( const ccell in,
long  sx,
long  nx,
long  sy,
long  ny 
)

Create a new sub cell matrix of nx*ny starting from(sx,sy)

◆ cbspline_prep()

ccell * cbspline_prep ( cmat x,
cmat y,
cmat z 
)

2D cubic spline interpolation preparation. x is the x coordinate vector of the 2-d grid. y is the y coordinate vector of the 2-d grid. z is defined on the 2-d grid. It is upto the user to make sure that the coordinate is increasingly ordered and evenly spaced .

The boundaries are handled in the same way is CX(spline). i.e. replace

\[f^\prime(0)=(f(1)-f(-1))/2\]

by

\[f^\prime(0)=(f(1)-f(0))\]

Otehr type of boundaries are handled in the same way.

2D cubic spline interpolation preparation. x is the x coordinate vector of the 2-d grid. y is the y coordinate vector of the 2-d grid. z is defined on the 2-d grid. It is upto the user to make sure that the coordinate is increasingly ordered and evenly spaced .

The boundaries are handled in the same way is ZX(spline). i.e. replace

\[f^\prime(0)=(f(1)-f(-1))/2\]

by

\[f^\prime(0)=(f(1)-f(0))\]

Otehr type of boundaries are handled in the same way.

◆ cbspline_eval()

cmat * cbspline_eval ( ccell coeff,
cmat x,
cmat y,
cmat xnew,
cmat ynew 
)

Evaluate 2D cubic spline at location defined 2-d arrays by xnew, ynew

◆ cmaprot()

void cmaprot ( anyarray  A_,
real  theta 
)

Rotate a or multiple 2d array ccw by angle

◆ cwritedata()

void cwritedata ( file_t *  fp,
const cmat A,
long  ncol 
)

Routines for input/output to bin/fits file. Function to write dense matrix data into a file pointer. Generally used by library developer

◆ creaddata()

cmat * creaddata ( file_t *  fp,
header_t header 
)

Function to read dense matrix into memory from file pointer. Generally used by library developer.

◆ cnew_mmap()

cmat * cnew_mmap ( long  nx,
long  ny,
const char *  keywords,
const char *  format,
  ... 
)

Create a new CX(mat) matrix object, mmapped from file. The file is truncated if already exists in rw mode.

Create a new ZX(mat) matrix object, mmapped from file. The file is truncated if already exists in rw mode.

◆ ccellnew_mmap()

ccell * ccellnew_mmap ( long  nx,
long  ny,
long nnx,
long nny,
const char *  keywords,
const char *  format,
  ... 
)

Create a new dense matrix cell object, mmapped from file. The file is truncated if already exists.

◆ ccellnewsame_mmap()

ccell * ccellnewsame_mmap ( long  nx,
long  ny,
long  mx,
long  my,
const char *  keywords,
const char *  format,
  ... 
)

Create a new dense matrix cell object, with identical blocks, mmapped from file. be aware that the data is not 8-byte aligned. The file is truncated if already exists.

◆ cread_mmap()

cmat * cread_mmap ( const char *  format,
  ... 
)

Map the file to memory in read only, shared mode.

◆ ccellread_mmap()

ccell * ccellread_mmap ( const char *  format,
  ... 
)

Map the file to memory in read only, shared mode.

◆ cspnew()

csp * cspnew ( long  nx,
long  ny,
long  nzmax 
)

Create a nx*ny sparse matrix with memory for nmax max elements allocated.

◆ cspref()

csp * cspref ( const csp A)

reference a sparse object.

◆ cspdup()

csp * cspdup ( const csp A)

copy a sparse matrix to another.

◆ cspnew2()

csp * cspnew2 ( const csp A)

Create a new sparse matrix of the same size as A.

◆ cspnewrandu()

csp * cspnewrandu ( long  nx,
long  ny,
const dcomplex  mean,
double  fill,
rand_t rstat 
)

Create a new sparse matrix and fill in uniform random numbers with filling factor of 'fill'

◆ cspsetnzmax()

void cspsetnzmax ( csp sp,
long  nzmax 
)

resize a sparse matrix

◆ csp_cast()

csp * csp_cast ( const cell A)

Cast a pointer to sparse array.

◆ cspfree_do()

void cspfree_do ( csp sp)

free a sparse matrix

◆ cspdisp()

void cspdisp ( const csp sp)

Display a sparse array

◆ cspcheck()

int cspcheck ( const csp sp)

Check a sparse array for wrong orders. Return 1 if is lower triangle, 2 if upper triangle, and 3 if diagonal.

◆ cspscale()

void cspscale ( csp A,
const dcomplex  beta 
)

inplace scale sparse matrix elements.

◆ cspscalex()

void cspscalex ( csp A,
const cmat xs 
)

inplace scale sparse matrix elements.

◆ cspscaley()

void cspscaley ( csp A,
const cmat ys 
)

inplace scale sparse matrix elements.

◆ cspcellref()

cspcell * cspcellref ( const cspcell A)

Reference a spcell array.

◆ cspcell_cast()

cspcell * cspcell_cast ( const cell A)

cast a cell object to CX(spcell) after checking

cast a cell object to ZX(spcell) after checking

◆ cspcellscale()

void cspcellscale ( cspcell A,
const dcomplex  beta 
)

inplace scale a CX(dspcell) object

inplace scale a ZX(dspcell) object

◆ cspnewdiag()

csp * cspnewdiag ( long  N,
dcomplex *  vec,
dcomplex  alpha 
)

Create a new sparse matrix with diagonal elements set to vec*alpha

◆ cspdiag()

cmat * cspdiag ( const csp A)

Extract diagonal element of A and return

◆ cspmuldiag()

void cspmuldiag ( csp *__restrict  A,
const dcomplex *  w,
dcomplex  alpha 
)

Multiply a sparse matrix inplace with a diagonal weighting matrix whose diagonal values are stored in w. W_ii=w_i; W_ij=0 if i!=j A=A*W*alpha; W is a diagonal sparse matrix. diag(W) is w multiply w[i] to all numbers in column[i]

◆ cspmv()

void cspmv ( cmat y,
const csp A,
const cmat *__restrict  x,
char  trans,
dcomplex  alpha 
)

sparse matrix multiply with a vector: y=y+op(A)*x*alpha op(A)=A if trans=='n' op(A)=A' if trans=='t' op(A)=conj(A') if trans=='c'

◆ cspmulcreal()

void cspmulcreal ( dcomplex *__restrict  y,
const csp A,
const dcomplex *__restrict  x,
double  alpha 
)

Multiply a sparse matrix with the real part of a complex vector: y=y+A*creal(x)*alpha

◆ cspmm()

void cspmm ( cmat **  yout,
const csp A,
const cmat x,
const char  trans[2],
const dcomplex  alpha 
)

sparse matrix multiply with dense matrix

◆ cmulsp()

void cmulsp ( cmat **  yout,
const cmat x,
const csp A,
const char  trans[2],
const dcomplex  alpha 
)

dense matrix multiply with sparse matrix, implemented by transpose all: y=x*A-->y'=A'*x'; conjugation is handled carefully.

◆ cspwdot()

comp cspwdot ( const cmat y,
const csp A,
const cmat x 
)

Multiply two vectors with weighting by sparse matrix. return y'*(A*x)

◆ cspcellwdot()

comp cspcellwdot ( const ccell y,
const cspcell A,
const ccell x 
)

Multiply two cell arrays with weighting by sparse matrix

◆ ccellmm()

void ccellmm ( panyarray  C0_,
const_anyarray  A_,
const_anyarray  B_,
const char  trans[2],
const double  alpha 
)

Compute A*B and add to C0.

C0=C0+op(A)*op(B)*alpha; op(A)=A if trans[0]=='n' op(A)=A' if trans[0]=='t' op(A)=conj(A') if trans[0]=='c'

op(B)=B if trans[1]=='n' op(B)=B' if trans[1]=='t' op(B)=conj(B') if trans[1]=='c'

A may be dense or sparse matrix.

2009-11-09: There was initially a beta parameter It was implemented wrongly for beta!=1 because for every call to dmm, the already accumulated ones are scaled. removed beta.

◆ ccellmm2()

ccell * ccellmm2 ( const ccell A,
const ccell B,
const char  trans[2] 
)

a different interface for multiplying cells.

◆ c2sp()

csp * c2sp ( cmat A,
double  thres 
)

Convert dense matrix A to sparse matrix with threshold.

◆ cspfull()

void cspfull ( cmat **  out0,
const csp A,
const char  trans,
const dcomplex  alpha 
)

Convert sparse matrix into dense matrix and add to output: out0=out0+full(A)*alpha

◆ cspcellfull()

void cspcellfull ( ccell **  out0,
const cspcell A,
const char  trans,
const dcomplex  alpha 
)

Expand sparse matrix cell to dense matrix cell.

◆ cspadd2()

csp * cspadd2 ( const csp A,
dcomplex  a,
const csp B,
dcomplex  b 
)

Added two sparse matrices: return A*a+B*b

◆ cspadd()

void cspadd ( csp **  A0,
dcomplex  alpha,
const csp B,
dcomplex  beta 
)

Add a sparse matrix to another: A0=A0+B

◆ ccelladd()

void ccelladd ( panyarray  pA_,
double  ac,
const_anyarray  B_,
double  bc 
)

Calculate A_=A_*ac+B_*bc;

Takes parameters of matrix, sparse matrix, or cell array of them.

◆ cspaddI()

csp * cspaddI ( const csp A,
dcomplex  alpha 
)

Add alpha times identity to a sparse matrix. If CX(sp) is not symmetric, only add diagonal to first nm*nm block for nm=min(nx,ny) Assume the the sparse array is sported correctly.

Add alpha times identity to a sparse matrix. If ZX(sp) is not symmetric, only add diagonal to first nm*nm block for nm=min(nx,ny) Assume the the sparse array is sported correctly.

◆ ccelladdI()

void ccelladdI ( anyarray  A_,
dcomplex  alpha 
)

Add alpha to diagnonal elements of A_. A_ can be matrix or sparse matrix.

◆ csptrans()

csp * csptrans ( const csp A)

Transpose a sparse array

◆ cspconj()

void cspconj ( csp A)

Take conjugation elementwise.

◆ cspmulsp()

csp * cspmulsp ( const csp A,
const csp B,
const char  trans[2] 
)

Multiply two sparse arrays and return the result op(A)*op(B)

◆ cspmulsp2()

void cspmulsp2 ( csp **  C0,
const csp A,
const csp B,
const char  trans[2],
const dcomplex  scale 
)

Multiply two sparse arrays and add to the third: C0=C0+op(A)*op(B)*scale

◆ cspcelltrans()

cspcell * cspcelltrans ( const cspcell spc)

Transpose a sparse cell

◆ cspcat()

csp * cspcat ( const csp A,
const csp B,
int  dim 
)

Concatenate two sparse array along dim dimension

◆ cspcell2sp()

csp * cspcell2sp ( const cspcell A)

Concatenate a dspcell to sparse array

◆ cspsum()

cmat * cspsum ( const csp A,
int  dim 
)

Sum elements of sparse array along dimension dim

◆ cspsumabs()

cmat * cspsumabs ( const csp A,
int  axis 
)

Sum abs of elements of sparse array along dimension dim

◆ cspclean()

void cspclean ( csp A)

Clean up a sparse array by dropping zeros

◆ cspdroptol()

void cspdroptol ( csp A,
double  thres 
)

Drop elements that are EPS times the largest value.

◆ cspcelldroptol()

void cspcelldroptol ( cspcell A,
double  thres 
)

Drop elements that are EPS times the largest value.

◆ cspdropemptycol()

lmat * cspdropemptycol ( csp A)

Drop empty columns

◆ cspsort()

void cspsort ( csp A)

Make sure the elements are sorted correctly. Does not change the location of data. can be done without harm.

◆ cspcellsort()

void cspcellsort ( cspcell A)

Make sure the elements are sorted correctly.

◆ cspsym()

void cspsym ( csp **  A)

symmetricize a sparse matrix and drop values below a threshold.

◆ cspcellsym()

void cspcellsym ( cspcell **  A)

symmetricize a sparse cell and drop values below a threshold.

◆ cspconvolvop()

csp * cspconvolvop ( cmat A)

Create a sparse convolution operator C with C(i,j)=A(i-j); A must be very sparse with only a view non-zero value otherwise C will be too full.

◆ cspperm()

csp * cspperm ( csp A,
int  reverse,
long pcol,
long prow 
)

Permute rows and columns of sparse matrix A;

◆ cspinvbdiag()

csp * cspinvbdiag ( const csp A,
long  bs 
)

Invert a SPD sparse matrix that is block diagonal with block sizes of bs.

◆ cspblockextract()

ccell * cspblockextract ( const csp A,
long  bs 
)

Extrat the diagonal blocks of size bs into cell arrays.

◆ ccell2m()

cmat * ccell2m ( const_anyarray  A_)

Convert dense or sparse matrix cell to matrix.

◆ cspwritedata()

void cspwritedata ( file_t *  fp,
const csp sp 
)

Function to write sparse matrix data into file pointed using a file pointer. Generally used by library developer. We do not convert data during saving, but rather do the conversion during reading.

◆ cspreaddata()

csp * cspreaddata ( file_t *  fp,
header_t header 
)

Function to read sparse matrix data from file pointer into memory. Used by library developer.

◆ cfft_free_plan()

void cfft_free_plan ( fft_t *  fft)

Free FFTW plans.

◆ cfft2()

void cfft2 ( cmat A,
int  dir 
)

Do 2d FFT transforms.

◆ cfft2i()

void cfft2i ( cmat A,
int  dir 
)

Do 2d inverse FFT (scaling factor of 1/(nx*ny) is applied)

◆ cfft2s()

void cfft2s ( cmat A,
int  dir 
)

Do 2d FFT transforms and scale the output by 1/sqrt(nx*ny)

◆ cfft2partial()

void cfft2partial ( cmat A,
int  ncomp,
int  dir 
)

Apply 2d FFT partially over ncomp \(\times\)ncomp region use two 1d plans that takes 1d fft through its column and selectly for its rows to produce smaller psf.

◆ cffttreat()

cmat * cffttreat ( cmat A)

returns IFFT(fftshift(FFT(A)))

◆ dcell_fft2()

void dcell_fft2 ( dcell dc,
int  dir 
)

Do FFT based on a 2 element cell array that contains real/imaginary parts respectively.

◆ dfft1plan_r2hc()

void dfft1plan_r2hc ( dmat A,
int  dir 
)

Create a fftw plan for 1d real to real FFT.

◆ dfft1()

void dfft1 ( dmat A,
int  dir 
)

Do 1d real to real FFT.