MAOS
Multithreaded Adaptive Optics Simulator
cell.h File Reference

Macros

#define cellfree(A)   if(A){cellfree_do(A); A=NULL;}
 
#define writebin(A, format...)   if(A) write_by_id(A, M_0, format)
 
#define writecell(A, format...)   write_by_id(A, M_0, format)
 
#define readbin(format...)   read_by_id(M_0, -1, format);
 
#define writebin_async(A, ncol)   writecell_async(A, ncol)
 
#define readdata(fp)   readdata_by_id(fp, 0, -1, 0)
 
#define writedata(fp, A)   writedata_by_id(fp, A, 0, 0)
 

Functions

cellcellnew (long nx, long ny)
 
void cellinit (panyarray A, long nx, long ny)
 
void cellinit2 (panyarray A, const_anyarray B)
 
void celldim (const_anyarray A_, long *nx, long *ny, long **nxs, long **nys)
 
void cellresize (anyarray in, long nx, long ny)
 
void cellfree_do (anyarray dc)
 
void writedata_by_id (file_t *fd, const_anyarray A, M_ID id, long ncol)
 
void write_by_id (const_anyarray dc, M_ID id, const char *format,...)
 
cellreaddata_by_id (file_t *fp, M_ID id, int level, header_t *header)
 
cellread_by_id (M_ID id, int level, const char *format,...)
 
void writecell_async (const_anyarray A, long ncol)
 
void writebin_header (anyarray dc, const char *keywords, const char *format,...)
 
cellreadsock (int sock)
 
void writesock (const_anyarray dc, int sock)
 

Detailed Description

Function for a generic cell. use CELL() to case to cell.

Macro Definition Documentation

◆ cellfree

#define cellfree (   A)    if(A){cellfree_do(A); A=NULL;}

free a cell array and zero the pointer.

◆ writebin

#define writebin (   A,
  format... 
)    if(A) write_by_id(A, M_0, format)

A generic routine for write data to file.

◆ readbin

#define readbin (   format...)    read_by_id(M_0, -1, format);

A generic routine for reading data from file. User need to cast the result. -1 means scan the file

Function Documentation

◆ cellnew()

cell* cellnew ( long  nx,
long  ny 
)

Create a generic cell array.

◆ cellinit()

void cellinit ( panyarray  A_,
long  nx,
long  ny 
)

check the size of cell array if exist. Otherwise create it

◆ cellinit2()

void cellinit2 ( panyarray  A_,
const_anyarray  B_ 
)

check the size of cell array if exist. Otherwise create it. m is created for dcell

◆ celldim()

void celldim ( const_anyarray  A_,
long nx,
long ny,
long **  nxs,
long **  nys 
)

Obtain the dimensions.

◆ cellresize()

void cellresize ( anyarray  A_,
long  nx,
long  ny 
)

Resize a generic cell array.

◆ cellfree_do()

void cellfree_do ( anyarray  A_)

free a mat or cell object.

◆ writedata_by_id()

void writedata_by_id ( file_t *  fp,
const_anyarray  A_,
M_ID  id,
long  ncol 
)

ncol: 0: normal writing. -1: initialize async data. >0: async writing.

◆ readdata_by_id()

cell* readdata_by_id ( file_t *  fp,
M_ID  id,
int  level,
header_t header 
)

Read data from file. level indicate intension, which may not match the file, in which case conversion is done. Usage: level=0: array of fundamental data. level=1: cell of fundamental data. level>1: cell of cell ... level==-1: automatically identify and read all data. top level non-cell data will be combined to a cell (e.g., fits) level<-1: only from recursive calling when the initial level is -1

id: magic number of request fundamental data. data is converted if it does not match magic number from the file.

There are two cases the file may be scanned to real all data, only at the top level though

  1. Found array of fundamental data by level is not 0. Used to wrap mat to cell or read fits file extension
  2. Found cell array with zero dimension.

◆ writecell_async()

void writecell_async ( const_anyarray  A,
long  ncol 
)

Calls writebin with build in fp

◆ writebin_header()

void writebin_header ( anyarray  Ac_,
const char *  keywords,
const char *  format,
  ... 
)

A generic routine for write data to file with separate keywords

◆ readsock()

cell* readsock ( int  sock)

A generic routine for reading data from socket. User need to cast the result. We dup the fd to avoid close it after read.

◆ writesock()

void writesock ( const_anyarray  A,
int  sock 
)

A generic routine for write data to socket. We dup the fd to avoid close it after read.