MAOS
Multithreaded Adaptive Optics Simulator
dmath.h File Reference

Macros

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

Typedefs

typedef real(* dminsearch_fun) (const real *x, void *info)
 

Functions

dmatdnew (long nx, long ny)
 
dmatdnew_file (long nx, long ny, const char *keywords, const char *format,...)
 
dmatdnew_do (long nx, long ny, real *p, mem_t *mem)
 
dmatdmat_cast (const void *A)
 
int dinit (dmat **A, long nx, long ny)
 
void dfree_content (dmat *A)
 
void dfree_do (dmat *A)
 
dmatdref (const dmat *in)
 
dmatdref_reshape (const dmat *in, long nx, long ny)
 
dmatdrefcols (const dmat *in, long icol, long ncol)
 
void dcols (dmat *out, const dmat *in, long icol, long ncol)
 
int dresize (dmat *A, long nx, long ny)
 
dmatdsub (const dmat *in, long sx, long nx, long sy, long ny)
 
dmatdcat (const dmat *in1, const dmat *in2, int dim)
 
dmatddup (const dmat *in)
 
void dzero (dmat *A)
 
int dzerocol (dmat *A, int icol)
 
uint32_t dhash (const dmat *A, uint32_t key)
 
void dcp (dmat **out0, const dmat *in)
 
dmatdtrans (const dmat *A)
 
void dset (dmat *A, const real val)
 
void dshow (const dmat *A, const char *format,...)
 
void dvecperm (dmat *out, const dmat *in, const long *perm)
 
void dvecpermi (dmat *out, const dmat *in, const long *perm)
 
int dflip (dmat *A, int axis)
 
real dvecsum (const real *__restrict p, long np)
 
real dsum (const dmat *A)
 
real dtrace (const dmat *A)
 
void dsort (dmat *A, int ascend)
 
void dmaxmin (const real *__restrict p, long N, real *max, real *min)
 
real dvecdot (const real *__restrict p1, const real *__restrict p2, const real *__restrict p3, long n)
 
void dnormalize_sum (real *__restrict p, long nloc, real norm)
 
void dnormalize_sumabs (real *__restrict p, long nloc, real norm)
 
void dnormalize_rms (real *__restrict p, long nx, real norm)
 
void dnormalize_max (real *__restrict p, long nloc, real max)
 
real dmax (const dmat *A)
 
real dvecmaxabs (const real *__restrict p, long n)
 
real dmaxabs (const dmat *A)
 
real dmin (const dmat *A)
 
real dsumabs (const dmat *in)
 
real dsumsq (const dmat *in)
 
real dsumdiffsq (const dmat *A, const dmat *B)
 
void dfftshift (dmat *A)
 
int dcpcorner2center (dmat *A, const dmat *B)
 
int dshift (dmat **B0, const dmat *A, int sx, int sy)
 
dcelldcell_cast (const cell *A)
 
dcelldcellnew2 (const dcell *A)
 
dcelldcellnew3 (long nx, long ny, long *nnx, long *nny)
 
dcelldcellnew_same (long nx, long ny, long mx, long my)
 
dcelldcellnew_file (long nx, long ny, long *nnx, long *nny, const char *keywords, const char *format,...)
 
dcelldcellnewsame_file (long nx, long ny, long mx, long my, const char *keywords, const char *format,...)
 
void dcellzero (dcell *dc)
 
void dcellset (dcell *dc, real alpha)
 
dcelldcelltrans (const dcell *A)
 
dcelldcellref (const dcell *in)
 
dcelldcelldup (const dcell *in)
 
void dcellcp (dcell **out0, const dcell *in)
 
dcelldcellreduce (const dcell *A, int dim)
 
dcelldcellcat (const dcell *A, const dcell *B, int dim)
 
void dcellcat2 (dcell **A, const dcell *B, int dim)
 
dcelldcellcat_each (const dcell *A, const dcell *B, int dim)
 
dcelld2cellref (const dmat *A, long *dims, long ndim)
 
void d2cell (dcell **B, const dmat *A, const dcell *ref)
 
dmatdcell_col (dcell *input, long icol)
 
real dcellsum (const dcell *A)
 
dmatdcellsum_each (const dcell *A)
 
uint32_t dcellhash (const dcell *A, uint32_t key)
 
int disnan (const dmat *A)
 
real dnorm (const dmat *in)
 
real dstd (const dmat *in)
 
void drandu (dmat *A, const real mean, rand_t *rstat)
 
void drandn (dmat *A, const real sigma, rand_t *rstat)
 
void dscale (dmat *A, real w)
 
real dinn (const dmat *A, const dmat *B)
 
real dwdot (const real *a, const dmat *w, const real *b)
 
void dcwm (dmat *A, const dmat *B)
 
void dcwm2 (dmat *A, const dmat *B1, real wt1, const dmat *B2, real wt2)
 
void dcwm3 (dmat *__restrict A, const dmat *__restrict W, const dmat *__restrict B1, const real wt1, const dmat *__restrict B2, const real wt2)
 
void dcwmcol (dmat *__restrict A, const dmat *__restrict B)
 
void dcwm3col (dmat *__restrict A, const dmat *__restrict W, const dmat *__restrict B1, const real wt1, const dmat *__restrict B2, const real wt2)
 
void dcwmrow (dmat *__restrict A, const dmat *__restrict B)
 
void dcwmcol2 (dmat *__restrict A, const dmat *__restrict B1, const real wt1, const dmat *__restrict B2, const real wt2)
 
void dcwmrow2 (dmat *__restrict A, const dmat *__restrict B1, const real wt1, const dmat *__restrict B2, const real wt2)
 
void dcwdiv (dmat *B, const dmat *A, real value)
 
void dmulvec (real *__restrict y, const dmat *__restrict A, const real *__restrict x, const real alpha)
 
void dmm (dmat **C0, const real beta, const dmat *A, const dmat *B, const char trans[2], const real alpha)
 
void dinvspd_inplace (dmat *A)
 
dmatdinvspd (const dmat *A)
 
void dinv_inplace (dmat *A)
 
dmatdinv (const dmat *A)
 
dmatdchol (const dmat *A)
 
dmatdmcc (const dmat *A, const dmat *wt)
 
dmatdimcc (const dmat *A, const dmat *wt)
 
dmatdtmcc (const dmat *A, const dmat *wt)
 
dmatdpinv2 (const dmat *A, const_anyarray W, real thres)
 
dmatdpinv (const dmat *A, const_anyarray W)
 
real ddiff (const dmat *A, const dmat *B)
 
int dcircle (dmat *A, real cx, real cy, real dx, real dy, real r, real val)
 
int dcircle_symbolic (dmat *A, real cx, real cy, real dx, real dy, real r)
 
void drotvec (dmat *A, const real theta)
 
void drotvect (dmat *A, const real theta)
 
void drotvecnn (dmat **B0, const dmat *A, real theta)
 
void dmulvec3 (real *y, const dmat *A, const real *x)
 
void dcorr (dmat **corr, const dmat *A, const dmat *B)
 
void dpara3 (real *grad, const dmat *corr)
 
void dcog (real *grad, const dmat *i0, real offsetx, real offsety, real thres, real bkgrnd, real flux)
 
void dshift2center (dmat *A, real offsetx, real offsety)
 
int dclip (dmat *A, real min, real max)
 
void dgramschmidt (dmat *Mod, real *amp)
 
void dmuldiag (dmat *A, const dmat *s)
 
void dcwpow (dmat *A, real power)
 
void dcwexp (dmat *A, real alpha)
 
void dcwpow_thres (dmat *A, real power, real thres)
 
void dsvd (dmat **U, dmat **Sdiag, dmat **VT, const dmat *A)
 
void dsvd_cache (dmat **U, dmat **Sdiag, dmat **VT, const dmat *A)
 
void dsvd_pow (dmat *A, real power, real thres)
 
void dexpm (dmat **out, real alpha, const dmat *A, real beta)
 
void dpolyval (dmat *A, dmat *p)
 
void daddI (dmat *A, real val)
 
void dadd (dmat **B0, real bc, const dmat *A, const real ac)
 
void dadd_relax (dmat **B0, real bc, const dmat *A, const real ac)
 
void daddcol (dmat *B, long icol, real bc, const dmat *A, const real ac)
 
void dadds (dmat *A, const real ac)
 
dmatdlogspace (real emin, real emax, long n)
 
dmatdlinspace (real min, real dx, long n)
 
dmatdinterp1 (const dmat *xin, const dmat *yin, const dmat *xnew, real y0)
 
dmatdinterp1_2 (const dmat *xyin, const dmat *xnew)
 
dmatdinterp1linear (const dmat *xin, const dmat *yin, const dmat *xnew, real y0)
 
dmatdinterp1log (const dmat *xin, const dmat *yin, const dmat *xnew, real y0)
 
void dblend (dmat *__restrict A, dmat *__restrict B, int overlap)
 
void dhistfill (dmat **out, const dmat *A, real center, real spacing, int n)
 
dmatdspline_prep (dmat *x, dmat *y)
 
dmatdspline_eval (dmat *coeff, dmat *x, dmat *xnew)
 
dmatdspline (dmat *x, dmat *y, dmat *xnew)
 
void dcwlog10 (dmat *A)
 
void dcwlog (dmat *A)
 
void dembed (dmat *__restrict A, const dmat *__restrict B, const real theta)
 
void dembedd (dmat *__restrict A, const dmat *__restrict B, const real theta)
 
real dfwhm (dmat *A)
 
void dgauss_fit (real *mr, real *ma, real *mb, real *theta, dmat *A, real thres)
 
real dgauss_width (dmat *A, real thres)
 
real dfwhm_gauss (dmat *A)
 
dmatdenc (const dmat *A, const dmat *dvec, int type, int nthread)
 
int dminsearch (real *x, int nmod, real ftol, int nmax, dminsearch_fun fun, void *info)
 
void dbessik (real x, real xnu, real *ri, real *rk, real *rip, real *rkp)
 
real dtrapz (const dmat *x, const dmat *y)
 
real dcellnorm (const dcell *in)
 
void dcellscale (anyarray A, real w)
 
void dcelldropempty (dcell **A0, int dim)
 
real dcellinn (const dcell *A, const dcell *B)
 
void dcellcwm (dcell *B, const dcell *A)
 
dcelldcellinvspd (dcell *A)
 
dcelldcellinv (dcell *A)
 
dcelldcellinvspd_each (dcell *A)
 
dcelldcellpinv2 (const dcell *A, const_anyarray W, real thres)
 
dcelldcellpinv (const dcell *A, const dspcell *W)
 
void dcellsvd_pow (dcell *A, real power, real thres)
 
void dcellcwpow (dcell *A, real power)
 
void dcelldropzero (dcell *B, real thres)
 
real dcelldiff (const dcell *A, const dcell *B)
 
int dcellclip (dcell *Ac, real min, real max)
 
dcelldcellsub (const dcell *in, long sx, long nx, long sy, long ny)
 
dcelldbspline_prep (dmat *x, dmat *y, dmat *z)
 
dmatdbspline_eval (dcell *coeff, dmat *x, dmat *y, dmat *xnew, dmat *ynew)
 
void dmaprot (anyarray A_, real theta)
 
void dwritedata (file_t *fp, const dmat *A, long ncol)
 
dmatdreaddata (file_t *fp, header_t *header)
 
dmatdnew_mmap (long nx, long ny, const char *keywords, const char *format,...)
 
dcelldcellnew_mmap (long nx, long ny, long *nnx, long *nny, const char *keywords, const char *format,...)
 
dcelldcellnewsame_mmap (long nx, long ny, long mx, long my, const char *keywords, const char *format,...)
 
dmatdread_mmap (const char *format,...)
 
dcelldcellread_mmap (const char *format,...)
 
dspdspnew (long nx, long ny, long nzmax)
 
dspdspref (dsp *A)
 
dspdspdup (const dsp *A)
 
dspdspnew2 (const dsp *A)
 
dspdspnewrandu (long nx, long ny, const real mean, real fill, rand_t *rstat)
 
void dspsetnzmax (dsp *sp, long nzmax)
 
dspdsp_cast (const cell *A)
 
void dspfree_do (dsp *sp)
 
void dspdisp (const dsp *sp)
 
int dspcheck (const dsp *sp)
 
void dspscale (dsp *A, const real beta)
 
void dspscalex (dsp *A, const dmat *xs)
 
void dspscaley (dsp *A, const dmat *ys)
 
dspcelldspcellref (const dspcell *in)
 
dspcelldspcell_cast (const cell *A)
 
void dspcellscale (dspcell *A, const real beta)
 
dspdspnewdiag (long N, real *vec, real alpha)
 
dmatdspdiag (const dsp *A)
 
void dspmuldiag (dsp *__restrict A, const real *w, real alpha)
 
void dspmv (dmat *y, const dsp *A, const dmat *__restrict x, char trans, real alpha)
 
void dspmulcreal (real *__restrict y, const dsp *A, const comp *__restrict x, real alpha)
 
void dspmm (dmat **yout, const dsp *A, const dmat *x, const char trans[2], const real alpha)
 
void dmulsp (dmat **yout, const dmat *x, const dsp *A, const char trans[2], const real alpha)
 
real dspwdinn (const dmat *y, const dsp *A, const dmat *x)
 
real dspcellwdinn (const dcell *y, const dspcell *A, const dcell *x)
 
void dcellmm (panyarray C0, const_anyarray A, const_anyarray B, const char trans[2], const real alpha)
 
dcelldcellmm2 (const dcell *A, const dcell *B, const char trans[2])
 
dspd2sp (dmat *A, real thres)
 
void dspfull (dmat **out0, const dsp *A, const char trans, const real f)
 
void dspcellfull (dcell **out0, const dspcell *A, const char trans, const real f)
 
dspdspadd2 (const dsp *A, real a, const dsp *B, real b)
 
void dspadd (dsp **A0, real alpha, const dsp *B, real beta)
 
void dcelladd (panyarray pA, real ac, const_anyarray B, real bc)
 
void dcelladdsp (dcell **pA, real ac, const dspcell *B, real bc)
 
void dspcelladd (dspcell **pA, real ac, const dspcell *B, real bc)
 
void dspaddI (dsp *A0, real alpha)
 
void dcelladdI (anyarray A, real alpha)
 
dspdsptrans (const dsp *A)
 
void dspconj (dsp *)
 
dspdspmulsp (const dsp *A, const dsp *B, const char trans[2])
 
void dspmulsp2 (dsp **C0, const dsp *A, const dsp *B, const char trans[2], const real scale)
 
dspcelldspcelltrans (const dspcell *spc)
 
dspdspcat (const dsp *A, const dsp *B, int type)
 
dspdspcell2sp (const dspcell *A)
 
dmatdspsum (const dsp *A, int col)
 
dmatdspsumabs (const dsp *A, int col)
 
void dspclean (dsp *A)
 
void dspdroptol (dsp *A, real thres)
 
void dspcelldroptol (dspcell *A, real thres)
 
void dspsort (dsp *A)
 
void dspcellsort (dspcell *A)
 
void dspsym (dsp **A)
 
void dspcellsym (dspcell **A)
 
dspdspconvolvop (dmat *A)
 
dspdspperm (dsp *A, int reverse, long *pcol, long *prow)
 
dspdspinvbdiag (const dsp *A, long bs)
 
dcelldspblockextract (const dsp *A, long bs)
 
dmatdcell2m (const_anyarray A)
 
void dspwritedata (file_t *fp, const dsp *sp)
 
dspdspreaddata (file_t *fp, header_t *header)
 

Function Documentation

◆ dnew()

dmat* dnew ( long  nx,
long  ny 
)

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

◆ dnew_file()

dmat* dnew_file ( long  nx,
long  ny,
const char *  keywords,
const char *  format,
  ... 
)

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

◆ dmat_cast()

dmat* dmat_cast ( const void *  A)

check and cast an object to matrix

◆ dinit()

int dinit ( dmat **  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.

◆ dfree_content()

void dfree_content ( dmat A)

free content of a matrix object.

◆ dfree_do()

void dfree_do ( dmat A)

free a matrix object.

◆ dref()

dmat* dref ( const dmat in)

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

◆ dref_reshape()

dmat* dref_reshape ( const dmat 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.

◆ drefcols()

dmat* drefcols ( const dmat in,
long  icol,
long  ncol 
)

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

◆ dcols()

void dcols ( dmat out,
const dmat 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.

◆ dresize()

int dresize ( dmat A,
long  nx,
long  ny 
)

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

  • 0 in dimension preserves original value.

◆ dsub()

dmat* dsub ( const dmat 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.

◆ dcat()

dmat* dcat ( const dmat in1,
const dmat in2,
int  dim 
)

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

◆ ddup()

dmat* ddup ( const dmat in)

duplicate a matrix

◆ dzero()

void dzero ( dmat A)

Set elements to zero.

◆ dzerocol()

int dzerocol ( dmat A,
int  icol 
)

Set column elements to zero.

◆ dhash()

uint32_t dhash ( const dmat A,
uint32_t  key 
)

Compute the hashlittle

◆ dcp()

void dcp ( dmat **  out0,
const dmat in 
)

copy the values from one matrix to another.

◆ dtrans()

dmat* dtrans ( const dmat A)

transpose a matrix

◆ dset()

void dset ( dmat A,
const double  val 
)

set values of each element in an matrix to val.

◆ dshow()

void dshow ( const dmat A,
const char *  format,
  ... 
)

display a matrix.

◆ dvecperm()

void dvecperm ( dmat out,
const dmat in,
const long perm 
)

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

◆ dvecpermi()

void dvecpermi ( dmat out,
const dmat in,
const long perm 
)

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

◆ dflip()

int dflip ( dmat A,
int  axis 
)

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

◆ dvecsum()

real dvecsum ( const double *__restrict  p,
long  nx 
)

sum of a vector using pointer and length

◆ dsum()

real dsum ( const dmat A)

create sum of all the elements in A.

◆ dtrace()

real dtrace ( const dmat A)

compute the trace (sum of diagonal elements)

◆ dsort()

void dsort ( dmat A,
int  ascend 
)

Sort all columns of A, in ascending order if ascend is non zero, otherwise in descending order.

◆ dmaxmin()

void dmaxmin ( const double *__restrict  p,
long  N,
double *  max,
double *  min 
)

Compute max, min and sum. Has to handle NAN nicely. Complex values are converted into magnitude during comparison.

◆ dvecdot()

real dvecdot ( const double *__restrict  p1,
const double *__restrict  p2,
const double *__restrict  p3,
long  n 
)

compute sum(p1.*p2.*p3)

◆ dnormalize_sum()

void dnormalize_sum ( double *__restrict  p,
long  nx,
double  norm 
)

normalize vector so that the sum is norm;

◆ dnormalize_sumabs()

void dnormalize_sumabs ( double *__restrict  p,
long  nx,
double  norm 
)

normalize vector so that the sum of abs is norm;

◆ dnormalize_rms()

void dnormalize_rms ( double *__restrict  p,
long  nx,
double  norm 
)

normalize vector so that the rms is norm

◆ dnormalize_max()

void dnormalize_max ( double *__restrict  p,
long  nx,
double  max 
)

normalize vector so that the max is max;

◆ dmax()

real dmax ( const dmat A)

find the maximum value

◆ dvecmaxabs()

real dvecmaxabs ( const double *__restrict  p,
long  n 
)

find the maximum of abs of all elements using pointer and count.

◆ dmaxabs()

real dmaxabs ( const dmat A)

find the maximum of abs of all elements

◆ dmin()

real dmin ( const dmat A)

find the minimum value

◆ dsumabs()

real dsumabs ( const dmat A)

compute the sum of abs of all elements

◆ dsumsq()

real dsumsq ( const dmat A)

compute the sum of A.*A

◆ dsumdiffsq()

real dsumdiffsq ( const dmat A,
const dmat B 
)

compute the sum of (A-B)^2

◆ dfftshift()

void dfftshift ( dmat A)

shift frequency components by n/2

◆ dcpcorner2center()

int dcpcorner2center ( dmat A,
const dmat B 
)

reorder B and embed/crop into center of A .

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

to

1 2
3 4

◆ dshift()

int dshift ( dmat **  B0,
const dmat A,
int  sx,
int  sy 
)

cyclic shift A by nx and ny to B.

4   3     1   2

2   1 to  3   4

◆ dcell_cast()

dcell* dcell_cast ( const cell A)

cast a cell object to actual cell after checking.

◆ dcellnew2()

dcell* dcellnew2 ( const dcell 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.

◆ dcellnew3()

dcell* dcellnew3 ( long  nx,
long  ny,
long nnx,
long nny 
)

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

◆ dcellnew_same()

dcell* dcellnew_same ( long  nx,
long  ny,
long  mx,
long  my 
)

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

◆ dcellnew_file()

dcell* dcellnew_file ( long  nx,
long  ny,
long nnx,
long nny,
const char *  keywords,
const char *  format,
  ... 
)

Calls cellnew3 with a filename to be saved to.

◆ dcellnewsame_file()

dcell* dcellnewsame_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.

◆ dcellzero()

void dcellzero ( dcell dc)

Setting all elements of a cell to zero.

◆ dcellset()

void dcellset ( dcell dc,
double  val 
)

setting all elements of a cell to alpha.

◆ dcelltrans()

dcell* dcelltrans ( const dcell A)

transpose a cell object

◆ dcellref()

dcell* dcellref ( const dcell in)

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

◆ dcelldup()

dcell* dcelldup ( const dcell in)

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

◆ dcellcp()

void dcellcp ( dcell **  A_,
const dcell B_ 
)

Copy B to A.

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

◆ dcellreduce()

dcell* dcellreduce ( const dcell A,
int  dim 
)

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

◆ dcellcat()

dcell* dcellcat ( const dcell A,
const dcell B,
int  dim 
)

concatenate two cell matrices along dimenstion 'dim'.

◆ dcellcat2()

void dcellcat2 ( dcell **  A,
const dcell B,
int  dim 
)

concatenate two cell matrices along dimenstion 'dim'.

◆ dcellcat_each()

dcell* dcellcat_each ( const dcell A,
const dcell B,
int  dim 
)

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

◆ d2cellref()

dcell* d2cellref ( const dmat A,
long dims,
long  ndim 
)

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

◆ d2cell()

void d2cell ( dcell **  B,
const dmat A,
const dcell 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.

◆ dcell_col()

dmat* dcell_col ( dcell input,
long  icol 
)

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

◆ dcellsum()

real dcellsum ( const dcell A)

create sum of all the elements in A.

◆ dcellsum_each()

dmat* dcellsum_each ( const dcell A)

return sum of each cell in a X(mat)

◆ dcellhash()

uint32_t dcellhash ( const dcell A,
uint32_t  key 
)

Compute the hashlittle

◆ disnan()

int disnan ( const dmat A)

Check for NaN in elements

◆ dnorm()

real dnorm ( const dmat A)

compute the norm(2) of A

◆ dstd()

real dstd ( const dmat A)

compute the standard deviation of A

◆ drandu()

void drandu ( dmat A,
const double  max,
rand_t rstat 
)

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

◆ drandn()

void drandn ( dmat A,
const double  sigma,
rand_t rstat 
)

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

◆ dscale()

void dscale ( dmat A,
double  w 
)

scale each element of A by w.

◆ dinn()

real dinn ( const dmat A,
const dmat B 
)

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

◆ dwdot()

real dwdot ( const double *  a,
const dmat w,
const double *  b 
)

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

◆ dcwm3()

void dcwm3 ( dmat *__restrict  A,
const dmat *__restrict  W,
const dmat *__restrict  B1,
double  wt1,
const dmat *__restrict  B2,
double  wt2 
)

component-wise multiply of three matrices. A=A.*W.*(B1*wt1+B2*wt2)

◆ dcwmcol()

void dcwmcol ( dmat *__restrict  A,
const dmat *__restrict  B 
)

Component-wise multiply each column of A with B A(:,i)=A(:,i).*B;

◆ dcwm3col()

void dcwm3col ( dmat *__restrict  A,
const dmat *__restrict  W,
const dmat *__restrict  B1,
const double  wt1,
const dmat *__restrict  B2,
const double  wt2 
)

component wise multiply of 2d complex matrix A,W and 1d vector B. A(:,i)=A(:,i).*W(:,i).*B;

◆ dcwmrow()

void dcwmrow ( dmat *__restrict  A,
const dmat *__restrict  B 
)

Component wise multiply each row of A with B. A(i,:)=A(i,:)*B

◆ dcwmcol2()

void dcwmcol2 ( dmat *__restrict  A,
const dmat *__restrict  B1,
const double  wt1,
const dmat *__restrict  B2,
const double  wt2 
)

component-wise multiply of columns of A with combination of B1 and B2: A(:,i)=A(:,i)*(B1*wt1+B2*wt2);

◆ dcwmrow2()

void dcwmrow2 ( dmat *__restrict  A,
const dmat *__restrict  B1,
const double  wt1,
const dmat *__restrict  B2,
const double  wt2 
)

component-wise multiply of rows of A with combination of B1 and B2: A(i,:)=A(i,:).*(B1*wt1+B2*wt2);

◆ dcwdiv()

void dcwdiv ( dmat B,
const dmat A,
double  value 
)

Component wise division B=B./A. 0/0 is replace by 'value';

◆ dmulvec()

void dmulvec ( double *__restrict  y,
const dmat *__restrict  A,
const double *__restrict  x,
const double  alpha 
)

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

◆ dmm()

void dmm ( dmat **  C0,
const double  beta,
const dmat A,
const dmat B,
const char  trans[2],
const double  alpha 
)

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

◆ dinvspd_inplace()

void dinvspd_inplace ( dmat 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

◆ dinvspd()

dmat* dinvspd ( const dmat A)

out of place version of dinvspd_inplace

◆ dinv_inplace()

void dinv_inplace ( dmat A)

inplace invert a general square matrix using lapack dgesv_

◆ dinv()

dmat* dinv ( const dmat A)

out of place version of dinv

◆ dchol()

dmat* dchol ( const dmat A)

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

◆ dmcc()

dmat* dmcc ( const dmat A,
const dmat wt 
)

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

◆ dimcc()

dmat* dimcc ( const dmat A,
const dmat wt 
)

compute inv(dmcc(A, wt))

◆ dtmcc()

dmat* dtmcc ( const dmat A,
const dmat wt 
)

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

◆ dpinv2()

dmat* dpinv2 ( const dmat A,
const_anyarray  W_,
double  thres 
)

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.

◆ dpinv()

dmat* dpinv ( const dmat A,
const_anyarray  W 
)

A convenient wrapper.

◆ ddiff()

real ddiff ( const dmat A,
const dmat B 
)

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

◆ dcircle()

int dcircle ( dmat A,
double  cx,
double  cy,
double  dx,
double  dy,
double  r,
double  val 
)

Generate a new gray pixel map based on bilinear influence functions used in mkw. It creates slightly larger map than an filled circle. 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'

◆ dcircle_symbolic()

int dcircle_symbolic ( dmat A,
double  cx,
double  cy,
double  dx,
double  dy,
double  r 
)

Mark valid grid points. If any direct neighbor of a point is within r, make the point valid. Parameters are the same as X(circle).

◆ drotvec()

void drotvec ( dmat 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.

◆ drotvect()

void drotvect ( dmat 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.

◆ drotvecnn()

void drotvecnn ( dmat **  B0,
const dmat 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';

◆ dmulvec3()

void dmulvec3 ( double *  y,
const dmat A,
const double *  x 
)

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

◆ dcorr()

void dcorr ( dmat **  pout,
const dmat A,
const dmat B 
)

Compute the correlation matrix.

◆ dpara3()

void dpara3 ( double *  grad,
const dmat corr 
)

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

◆ dcog()

void dcog ( double *  grad,
const dmat 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.

◆ dshift2center()

void dshift2center ( dmat A,
double  offsetx,
double  offsety 
)

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

◆ dcwpow()

void dcwpow ( dmat A,
double  power 
)

Raise all elements to power 'power'

◆ dcwexp()

void dcwexp ( dmat A,
double  alpha 
)

compute exponential of all elements after scaling by alpha

◆ dsvd()

void dsvd ( dmat **  U,
dmat **  Sdiag,
dmat **  VT,
const dmat A 
)

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

◆ dsvd_cache()

void dsvd_cache ( dmat **  U,
dmat **  Sdiag,
dmat **  VT,
const dmat A 
)

Compute SVD with caching.

◆ dsvd_pow()

void dsvd_pow ( dmat A,
double  power,
double  thres 
)

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
[in,out]AThe matrix
[in]powerpower of eigen values. usually -1 for inverse
[in]thresSVD inverse threshold

◆ dexpm()

void dexpm ( dmat **  out,
double  alpha,
const dmat 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.

◆ dpolyval()

void dpolyval ( dmat A,
dmat p 
)

Compute polynomial functional value inplace

◆ dadd()

void dadd ( dmat **  B0,
double  bc,
const dmat A,
const double  ac 
)

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

◆ dadd_relax()

void dadd_relax ( dmat **  B0,
double  bc,
const dmat A,
const double  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.

◆ daddcol()

void daddcol ( dmat B,
long  icol,
double  bc,
const dmat A,
const double  ac 
)

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

◆ dlogspace()

dmat* dlogspace ( double  emin,
double  emax,
long  n 
)

Create log spaced vector.

◆ dlinspace()

dmat* dlinspace ( double  min,
double  dx,
long  n 
)

Create linearly spaced vector.

◆ dinterp1()

dmat* dinterp1 ( const dmat xin_,
const dmat yin_,
const dmat xnew,
double  ydefault 
)

Interpolation of 1d array

◆ dinterp1linear()

dmat* dinterp1linear ( const dmat xin,
const dmat yin,
const dmat xnew,
double  ydefault 
)

Interpolate using linear interp. xin is the coordinate of yin. xnew is the coordinate of the output.

◆ dinterp1log()

dmat* dinterp1log ( const dmat xin,
const dmat yin,
const dmat xnew,
double  ydefault 
)

Interpolate using log(xin) and log(xnew) xin is the coordinate of yin. xnew is the coordinate of the output.

◆ dblend()

void dblend ( dmat *__restrict  A,
dmat *__restrict  B,
int  overlap 
)

blend B into center of A with width of overlap. The center (size is B->nx-overlap, B->ny-overlap) of A is replaced by center of B . The overlapping area is blended

◆ dhistfill()

void dhistfill ( dmat **  out,
const dmat A,
double  center,
double  spacing,
int  n 
)

For each entry in A, call repeatly to collect its histogram, centered at center, spaced by spacing, for n bins in total. center if at bin n/2.

◆ dspline_prep()

dmat* dspline_prep ( dmat x,
dmat y 
)

1D Cubic spline interpolation preparation. if x has only 1 column: x is the coordinate. y is the function value. if x has two columns: first column is the coordinate, y is null.

It is upto the user to make sure that the coordinate is increasingly ordered and evenly spaced .

If the values of a function \(f(x)\) and its derivative are know at x=0, and x=1 (normalized coordinate), then the function can be interpolated on the interval [0,1] using a third degree polynomial. This is called cubic interpolation. The formula of this polynomial can be easily derived.

A third degree polynomial and its derivative:

\[ f(x)=ax^3+bx^2+cx+d \]

\[ f(x)=3ax^3+2bx+c \]

The coefficients can be derived from the value and derivatives:

\begin{eqnarray*} a&=&2f(0)-2f(1)+f^\prime (0)+f^\prime(1)\\ b&=&-3f(0)+3f(1)-2f^\prime(0)-f^\prime(0)\\ c&=&f^\prime(0)\\ d&=&f(0)\\ \end{eqnarray*}

the derivatives can be computed as

\begin{eqnarray*} f^\prime(0)&=&\frac{f(1)-f(-1)}{2}\\ f^\prime(1)&=&\frac{f(2)-f(0)}{2}\\ \end{eqnarray*}

so we have the formula

\begin{eqnarray*} a&=&-0.5 f(-1) + 1.5 f(0) - 1.5 f(1) + 0.5 f(2)\\ b&=& f(-1) - 2.5 f(0) + 2 f(1) - 0.5 f(2)\\ c&=&-0.5 f(-1) + 0.5 f(1) \\ d&=& f(0) \\ \end{eqnarray*}

for the boundary pints, 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.

see www.paulinternet.nl/?page=bicubicx

◆ dspline_eval()

dmat* dspline_eval ( dmat coeff,
dmat x,
dmat xnew 
)

Evluate the cubic spline represented by nx5 matrix coeff, at location array xnew.

◆ dspline()

dmat* dspline ( dmat x,
dmat y,
dmat xnew 
)

Do 1D cubic spline all at once by calling X(spline_prep) and X(spline_evald)

◆ dcwlog10()

void dcwlog10 ( dmat A)

Do a component wise log10 on each element of A.

◆ dcwlog()

void dcwlog ( dmat A)

Do a component wise log10 on each element of A.

◆ dembed()

void dembed ( dmat *__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.

◆ dembedd()

void dembedd ( dmat *__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.

◆ dfwhm()

real dfwhm ( dmat 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))*X(gauss_width).

◆ dgauss_fit()

void dgauss_fit ( double *  mr,
double *  ma,
double *  mb,
double *  angle,
dmat 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.

◆ dgauss_width()

real dgauss_width ( dmat A,
double  thres 
)

A convenient wrapper

◆ dfwhm_gauss()

real dfwhm_gauss ( dmat A)

Use gauss fit to compute fwhm

◆ denc()

dmat* denc ( const dmat psf,
const dmat dvec,
int  type,
int  nthread 
)

Compute the enclosed energy or azimuthal average of a.

Parameters
psfThe input array
dvecThe diameter for enclosed energy, or radius for azimuthal average
typeThe type. -1: azimuthal average, 0: within a square, 1: within a circle, 2: within a slit
nthreadNumber of CPU threads to use.

◆ dminsearch()

int dminsearch ( double *  x,
int  nmod,
double  ftol,
int  nmax,
dminsearch_fun  fun,
void *  info 
)

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

◆ dbessik()

void dbessik ( double  x,
double  xnu,
double *  ri,
double *  rk,
double *  rip,
double *  rkp 
)

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

◆ dcellnorm()

real dcellnorm ( const dcell A)

compute norm2.

◆ dcellscale()

void dcellscale ( anyarray  A_,
double  w 
)

scale each element of A.

◆ dcelldropempty()

void dcelldropempty ( dcell **  A0,
int  dim 
)

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

◆ dcellinn()

real dcellinn ( const dcell A,
const dcell B 
)

Compute the inner produce of two dcell.

◆ dcellcwm()

void dcellcwm ( dcell B,
const dcell A 
)

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

◆ dcellinvspd()

dcell* dcellinvspd ( dcell A)

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

◆ dcellinv()

dcell* dcellinv ( dcell A)

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

◆ dcellinvspd_each()

dcell* dcellinvspd_each ( dcell A)

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

◆ dcellpinv2()

dcell* dcellpinv2 ( const dcell A,
const_anyarray  W_,
double  thres 
)

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]thresSVD inverse threshold

◆ dcellpinv()

dcell* dcellpinv ( const dcell A,
const dspcell W 
)
Parameters
[in]AThe matrix to pseudo invert
[in]WThe weighting matrix.

◆ dcellsvd_pow()

void dcellsvd_pow ( dcell A,
double  power,
double  thres 
)

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

◆ dcellcwpow()

void dcellcwpow ( dcell A,
double  power 
)

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

◆ dcelldropzero()

void dcelldropzero ( dcell B,
double  thres 
)

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

◆ dcelldiff()

real dcelldiff ( const dcell A,
const dcell B 
)

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

◆ dcellclip()

int dcellclip ( dcell Ac,
double  min,
double  max 
)

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

◆ dcellsub()

dcell* dcellsub ( const dcell in,
long  sx,
long  nx,
long  sy,
long  ny 
)

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

◆ dbspline_prep()

dcell* dbspline_prep ( dmat x,
dmat y,
dmat 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 X(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.

◆ dbspline_eval()

dmat* dbspline_eval ( dcell coeff,
dmat x,
dmat y,
dmat xnew,
dmat ynew 
)

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

◆ dmaprot()

void dmaprot ( anyarray  A_,
real  theta 
)

Rotate a or multiple 2d array ccw by angle

◆ dwritedata()

void dwritedata ( file_t *  fp,
const dmat 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

◆ dreaddata()

dmat* dreaddata ( file_t *  fp,
header_t header 
)

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

◆ dnew_mmap()

dmat* dnew_mmap ( long  nx,
long  ny,
const char *  keywords,
const char *  format,
  ... 
)

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

◆ dcellnew_mmap()

dcell* dcellnew_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.

◆ dcellnewsame_mmap()

dcell* dcellnewsame_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.

◆ dread_mmap()

dmat* dread_mmap ( const char *  format,
  ... 
)

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

◆ dcellread_mmap()

dcell* dcellread_mmap ( const char *  format,
  ... 
)

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

◆ dspnew()

dsp* dspnew ( long  nx,
long  ny,
long  nzmax 
)

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

◆ dspref()

dsp* dspref ( dsp A)

reference a sparse object.

◆ dspdup()

dsp* dspdup ( const dsp A)

copy a sparse matrix to another.

◆ dspnew2()

dsp* dspnew2 ( const dsp A)

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

◆ dspnewrandu()

dsp* dspnewrandu ( long  nx,
long  ny,
const double  mean,
double  fill,
rand_t rstat 
)

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

◆ dspsetnzmax()

void dspsetnzmax ( dsp sp,
long  nzmax 
)

resize a sparse matrix

◆ dsp_cast()

dsp* dsp_cast ( const cell A)

Cast a pointer to sparse array.

◆ dspfree_do()

void dspfree_do ( dsp sp)

free a sparse matrix

◆ dspdisp()

void dspdisp ( const dsp sp)

Display a sparse array

◆ dspcheck()

int dspcheck ( const dsp sp)

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

◆ dspscale()

void dspscale ( dsp A,
const double  beta 
)

inplace scale sparse matrix elements.

◆ dspscalex()

void dspscalex ( dsp A,
const dmat xs 
)

inplace scale sparse matrix elements.

◆ dspscaley()

void dspscaley ( dsp A,
const dmat ys 
)

inplace scale sparse matrix elements.

◆ dspcellref()

dspcell* dspcellref ( const dspcell A)

Reference a spcell array.

◆ dspcell_cast()

dspcell* dspcell_cast ( const cell A)

cast a cell object to X(spcell) after checking

◆ dspcellscale()

void dspcellscale ( dspcell A,
const double  beta 
)

inplace scale a X(dspcell) object

◆ dspnewdiag()

dsp* dspnewdiag ( long  N,
double *  vec,
double  alpha 
)

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

◆ dspdiag()

dmat* dspdiag ( const dsp A)

Extract diagonal element of A and return

◆ dspmuldiag()

void dspmuldiag ( dsp *__restrict  A,
const double *  w,
double  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]

◆ dspmv()

void dspmv ( dmat y,
const dsp A,
const dmat *__restrict  x,
char  trans,
double  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'

◆ dspmulcreal()

void dspmulcreal ( double *__restrict  y,
const dsp 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

◆ dspmm()

void dspmm ( dmat **  yout,
const dsp A,
const dmat x,
const char  trans[2],
const double  alpha 
)

sparse matrix multiply with dense matrix

◆ dmulsp()

void dmulsp ( dmat **  yout,
const dmat x,
const dsp A,
const char  trans[2],
const double  alpha 
)

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

◆ dspwdinn()

real dspwdinn ( const dmat y,
const dsp A,
const dmat x 
)

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

◆ dspcellwdinn()

real dspcellwdinn ( const dcell y,
const dspcell A,
const dcell x 
)

Multiply two cell arrays with weighting by sparse matrix

◆ dcellmm()

void dcellmm ( 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.

◆ dcellmm2()

dcell* dcellmm2 ( const dcell A,
const dcell B,
const char  trans[2] 
)

a different interface for multiplying cells.

◆ d2sp()

dsp* d2sp ( dmat A,
double  thres 
)

Convert dense matrix A to sparse matrix with threshold.

◆ dspfull()

void dspfull ( dmat **  out0,
const dsp A,
const char  trans,
const double  alpha 
)

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

◆ dspcellfull()

void dspcellfull ( dcell **  out0,
const dspcell A,
const char  trans,
const double  alpha 
)

Expand sparse matrix cell to dense matrix cell.

◆ dspadd2()

dsp* dspadd2 ( const dsp A,
double  a,
const dsp B,
double  b 
)

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

◆ dspadd()

void dspadd ( dsp **  A0,
double  alpha,
const dsp B,
double  beta 
)

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

◆ dcelladd()

void dcelladd ( 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.

◆ dspaddI()

void dspaddI ( dsp A,
double  alpha 
)

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

◆ dcelladdI()

void dcelladdI ( anyarray  A_,
double  alpha 
)

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

◆ dsptrans()

dsp* dsptrans ( const dsp A)

Transpose a sparse array

◆ dspconj()

void dspconj ( dsp A)

Take conjugation elementwise.

◆ dspmulsp()

dsp* dspmulsp ( const dsp A,
const dsp B,
const char  trans[2] 
)

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

◆ dspmulsp2()

void dspmulsp2 ( dsp **  C0,
const dsp A,
const dsp B,
const char  trans[2],
const double  scale 
)

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

◆ dspcelltrans()

dspcell* dspcelltrans ( const dspcell spc)

Transpose a sparse cell

◆ dspcat()

dsp* dspcat ( const dsp A,
const dsp B,
int  dim 
)

Concatenate two sparse array along dim dimension

◆ dspcell2sp()

dsp* dspcell2sp ( const dspcell A)

Concatenate a dspcell to sparse array

◆ dspsum()

dmat* dspsum ( const dsp A,
int  dim 
)

Sum elements of sparse array along dimension dim

◆ dspsumabs()

dmat* dspsumabs ( const dsp A,
int  col 
)

Sum abs of elements of sparse array along dimension dim

◆ dspclean()

void dspclean ( dsp A)

Clean up a sparse array by dropping zeros

◆ dspdroptol()

void dspdroptol ( dsp A,
double  thres 
)

Drop elements that are EPS times the largest value.

◆ dspcelldroptol()

void dspcelldroptol ( dspcell A,
double  thres 
)

Drop elements that are EPS times the largest value.

◆ dspsort()

void dspsort ( dsp A)

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

◆ dspcellsort()

void dspcellsort ( dspcell A)

Make sure the elements are sorted correctly.

◆ dspsym()

void dspsym ( dsp **  A)

symmetricize a sparse matrix and drop values below a threshold.

◆ dspcellsym()

void dspcellsym ( dspcell **  A)

symmetricize a sparse cell and drop values below a threshold.

◆ dspconvolvop()

dsp* dspconvolvop ( dmat 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.

◆ dspperm()

dsp* dspperm ( dsp A,
int  reverse,
long pcol,
long prow 
)

Permute rows and columns of sparse matrix A;

◆ dspinvbdiag()

dsp* dspinvbdiag ( const dsp A,
long  bs 
)

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

◆ dspblockextract()

dcell* dspblockextract ( const dsp A,
long  bs 
)

Extrat the diagonal blocks of size bs into cell arrays.

◆ dcell2m()

dmat* dcell2m ( const_anyarray  A_)

Convert dense or sparse matrix cell to matrix.

◆ dspwritedata()

void dspwritedata ( file_t *  fp,
const dsp 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.

◆ dspreaddata()

dsp* dspreaddata ( file_t *  fp,
header_t header 
)

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