42 #if defined(__cplusplus) 50 #define m_move mesch_m_move 53 #if defined(__MWERKS__) && !defined(_MSC_VER) 56 #include <sys/types.h> 103 extern char *malloc(), *calloc(), *realloc();
105 extern void *malloc(
size_t),
106 *calloc(
size_t,
size_t),
107 *realloc(
void *,
size_t);
120 #define NEW(type) ((type *)calloc(1,sizeof(type))) 123 #define NEW_A(num,type) ((type *)calloc((unsigned)(num),sizeof(type))) 126 #define RENEW(var,num,type) \ 127 ((var)=(type *)((var) ? \ 128 realloc((char *)(var),(unsigned)(num)*sizeof(type)) : \ 129 calloc((unsigned)(num),sizeof(type)))) 131 #define MEMCOPY(from,to,n_items,type) \ 132 MEM_COPY((char *)(from),(char *)(to),(unsigned)(n_items)*sizeof(type)) 136 #define NEW(type) ((type *)calloc((size_t)1,(size_t)sizeof(type))) 139 #define NEW_A(num,type) ((type *)calloc((size_t)(num),(size_t)sizeof(type))) 142 #define RENEW(var,num,type) \ 143 ((var)=(type *)((var) ? \ 144 realloc((char *)(var),(size_t)((num)*sizeof(type))) : \ 145 calloc((size_t)(num),(size_t)sizeof(type)))) 147 #define MEMCOPY(from,to,n_items,type) \ 148 MEM_COPY((char *)(from),(char *)(to),(unsigned)(n_items)*sizeof(type)) 154 #define max(a,b) ((a) > (b) ? (a) : (b)) 157 #define min(a,b) ((a) > (b) ? (b) : (a)) 213 #define M_FREE(mat) ( m_free(mat), (mat)=(MAT *)NULL ) 214 #define V_FREE(vec) ( v_free(vec), (vec)=(VEC *)NULL ) 215 #define PX_FREE(px) ( px_free(px), (px)=(PERM *)NULL ) 216 #define IV_FREE(iv) ( iv_free(iv), (iv)=(IVEC *)NULL ) 225 #define v_entry(x,i) (((i) < 0 || (i) >= (x)->dim) ? \ 226 error(E_BOUNDS,"v_entry"), 0.0 : (x)->ve[i] ) 229 #define v_set_val(x,i,val) ((x)->ve[i] = ((i) < 0 || (i) >= (x)->dim) ? \ 230 error(E_BOUNDS,"v_set_val"), 0.0 : (val)) 233 #define v_add_val(x,i,val) ((x)->ve[i] += ((i) < 0 || (i) >= (x)->dim) ? \ 234 error(E_BOUNDS,"v_add_val"), 0.0 : (val)) 237 #define v_sub_val(x,i,val) ((x)->ve[i] -= ((i) < 0 || (i) >= (x)->dim) ? \ 238 error(E_BOUNDS,"v_sub_val"), 0.0 : (val)) 241 #define m_entry(A,i,j) (((i) < 0 || (i) >= (A)->m || \ 242 (j) < 0 || (j) >= (A)->n) ? \ 243 error(E_BOUNDS,"m_entry"), 0.0 : (A)->me[i][j] ) 246 #define m_set_val(A,i,j,val) ((A)->me[i][j] = ((i) < 0 || (i) >= (A)->m || \ 247 (j) < 0 || (j) >= (A)->n) ? \ 248 error(E_BOUNDS,"m_set_val"), 0.0 : (val) ) 251 #define m_add_val(A,i,j,val) ((A)->me[i][j] += ((i) < 0 || (i) >= (A)->m || \ 252 (j) < 0 || (j) >= (A)->n) ? \ 253 error(E_BOUNDS,"m_add_val"), 0.0 : (val) ) 256 #define m_sub_val(A,i,j,val) ((A)->me[i][j] -= ((i) < 0 || (i) >= (A)->m || \ 257 (j) < 0 || (j) >= (A)->n) ? \ 258 error(E_BOUNDS,"m_sub_val"), 0.0 : (val) ) 262 #define v_entry(x,i) ((x)->ve[i]) 265 #define v_set_val(x,i,val) ((x)->ve[i] = (val)) 268 #define v_add_val(x,i,val) ((x)->ve[i] += (val)) 271 #define v_sub_val(x,i,val) ((x)->ve[i] -= (val)) 274 #define m_entry(A,i,j) ((A)->me[i][j]) 277 #define m_set_val(A,i,j,val) ((A)->me[i][j] = (val) ) 280 #define m_add_val(A,i,j,val) ((A)->me[i][j] += (val) ) 283 #define m_sub_val(A,i,j,val) ((A)->me[i][j] -= (val) ) 336 int fin_int(FILE *
fp,
char *
s,
int low,
int high);
355 #define v_output(vec) v_foutput(stdout,vec) 356 #define v_input(vec) v_finput(stdin,vec) 357 #define m_output(mat) m_foutput(stdout,mat) 358 #define m_input(mat) m_finput(stdin,mat) 359 #define px_output(px) px_foutput(stdout,px) 360 #define px_input(px) px_finput(stdin,px) 361 #define iv_output(iv) iv_foutput(stdout,iv) 362 #define iv_input(iv) iv_finput(stdin,iv) 365 #define finput(fp,prompt,fmt,var) \ 366 ( ( isatty(fileno(fp)) ? fprintf(stderr,prompt) : skipjunk(fp) ), \ 368 #define input(prompt,fmt,var) finput(stdin,prompt,fmt,var) 369 #define fprompter(fp,prompt) \ 370 ( isatty(fileno(fp)) ? fprintf(stderr,prompt) : skipjunk(fp) ) 371 #define prompter(prompt) fprompter(stdin,prompt) 372 #define y_or_n(s) fy_or_n(stdin,s) 373 #define in_int(s,lo,hi) fin_int(stdin,s,lo,hi) 374 #define in_double(s,lo,hi) fin_double(stdin,s,lo,hi) 388 *
m_move(
MAT *in,
int,
int,
int,
int,
MAT *out,
int,
int),
403 #define m_copy(in,out) _m_copy(in,out,0,0) 404 #define v_copy(in,out) _v_copy(in,out,0) 441 #ifdef PROTOTYPES_IN_STRUCT 485 #define in_prod(a,b) _in_prod(a,b,0) 510 #define v_norm1(x) _v_norm1(x,VNULL) 511 #define v_norm2(x) _v_norm2(x,VNULL) 512 #define v_norm_inf(x) _v_norm_inf(x,VNULL) 562 #define set_row(mat,row,vec) _set_row(mat,row,vec,0) 564 #define set_col(mat,col,vec) _set_col(mat,col,vec,0) 631 #define VNULL ((VEC *)NULL) 632 #define MNULL ((MAT *)NULL) 633 #define PNULL ((PERM *)NULL) 634 #define IVNULL ((IVEC *)NULL) 635 #define BDNULL ((BAND *)NULL) 685 #if defined(__cplusplus) int m_resize_vars(int m, int n,...)
IVEC * iv_finput(FILE *fp, IVEC *out)
VEC * mv_move(MAT *in, int, int, int, int, VEC *out, int)
MAT * m_mlt(MAT *A, MAT *B, MAT *out)
VEC * _v_map(double(*f)(), void *, VEC *, VEC *)
VEC * v_sort(VEC *, PERM *)
int v_get_vars(int dim,...)
PERM * px_copy(PERM *in, PERM *out)
PERM * px_inv(PERM *px, PERM *out)
VEC * v_resize(VEC *, int)
int iv_get_vars(int dim,...)
int v_resize_vars(int new_dim,...)
int iv_free_vars(IVEC **,...)
BAND * mat2band(MAT *A, int lb, int ub, BAND *bA)
void __mltadd__(Real *, Real *, double, int)
MAT * m_transp(MAT *A, MAT *out)
MAT * m_resize(MAT *, int, int)
MAT * px_cols(PERM *px, MAT *A, MAT *out)
MAT * mtrm_mlt(MAT *A, MAT *B, MAT *out)
MAT * sub_mat(MAT *A, u_int, u_int, u_int, u_int, MAT *out)
void px_foutput(FILE *fp, PERM *px)
MAT * _m_copy(MAT *in, MAT *out, u_int i0, u_int j0)
int px_resize_vars(int new_dim,...)
void px_dump(FILE *, PERM *px)
VEC * vm_mlt(MAT *, VEC *, VEC *)
double __ip__(Real *, Real *, int)
void mrandlist(Real *x, int len)
int m_get_vars(int m, int n,...)
double m_norm_inf(MAT *A)
void __zero__(Real *, int)
double v_min(VEC *, int *)
MAT * mmtr_mlt(MAT *A, MAT *B, MAT *out)
double _v_norm_inf(VEC *x, VEC *scale)
VEC * v_finput(FILE *fp, VEC *out)
MAT * m_add(MAT *A, MAT *B, MAT *out)
VEC * vm_mltadd(VEC *x, VEC *y, MAT *A, double s, VEC *out)
VEC * px_vec(PERM *, VEC *, VEC *)
PERM * px_transp(PERM *px, u_int i, u_int j)
double v_max(VEC *, int *)
int const size_t const size_t n
IVEC * iv_move(IVEC *in, int, int, IVEC *out, int)
int iv_resize_vars(int new_dim,...)
int v_free_vars(VEC **,...)
BAND * bd_copy(BAND *in, BAND *out)
int fin_int(FILE *fp, char *s, int low, int high)
VEC * mv_mlt(MAT *, VEC *, VEC *)
PERM * px_resize(PERM *, int)
MAT * m_finput(FILE *fp, MAT *out)
void iv_dump(FILE *fp, IVEC *ix)
BAND * bd_transp(BAND *in, BAND *out)
void __smlt__(Real *, double, Real *, int)
VEC * sub_vec(VEC *, int, int, VEC *)
MAT * swap_cols(MAT *, int, int, int, int)
MAT * px_rows(PERM *px, MAT *A, MAT *out)
VEC * v_mltadd(VEC *, VEC *, double, VEC *)
IVEC * iv_sort(IVEC *ix, PERM *order)
MAT * _set_col(MAT *A, u_int i, VEC *out, u_int j0)
IVEC * iv_copy(IVEC *in, IVEC *out)
IVEC * iv_resize(IVEC *, int)
VEC * sv_mlt(double, VEC *, VEC *)
IVEC * iv_sub(IVEC *ix, IVEC *iy, IVEC *out)
IVEC * iv_add(IVEC *ix, IVEC *iy, IVEC *out)
int fy_or_n(FILE *fp, char *s)
void __add__(Real *, Real *, Real *, int)
VEC * v_sub(VEC *, VEC *, VEC *)
VEC * mv_mltadd(VEC *x, VEC *y, MAT *A, double s, VEC *out)
PERM * px_finput(FILE *fp, PERM *out)
VEC * pxinv_vec(PERM *, VEC *, VEC *)
MAT * vm_move(VEC *in, int, MAT *out, int, int, int, int)
void iv_foutput(FILE *fp, IVEC *ix)
MAT * band2mat(BAND *bA, MAT *A)
double _v_norm2(VEC *x, VEC *scale)
VEC * get_row(MAT *, u_int, VEC *)
MAT * _set_row(MAT *A, u_int j, VEC *out, u_int i0)
VEC * v_slash(VEC *, VEC *, VEC *)
VEC * v_add(VEC *, VEC *, VEC *)
void v_dump(FILE *fp, VEC *x)
double _v_norm1(VEC *x, VEC *scale)
int px_free_vars(PERM **,...)
VEC * get_col(MAT *, u_int, VEC *)
VEC * v_linlist(VEC *out, VEC *v1, double a1,...)
VEC * v_move(VEC *in, int, int, VEC *out, int)
VEC * _v_copy(VEC *in, VEC *out, u_int i0)
MAT * sm_mlt(double s, MAT *A, MAT *out)
MAT * ms_mltadd(MAT *A, MAT *B, double s, MAT *out)
void __sub__(Real *, Real *, Real *, int)
void m_foutput(FILE *fp, MAT *A)
BAND * bd_get(int, int, int)
void v_foutput(FILE *fp, VEC *x)
double _in_prod(VEC *x, VEC *y, u_int i0)
int px_get_vars(int dim,...)
void m_dump(FILE *fp, MAT *a)
PERM * px_mlt(PERM *px1, PERM *px2, PERM *out)
MAT * m_sub(MAT *A, MAT *B, MAT *out)
BAND * bd_resize(BAND *, int, int, int)
double m_norm_frob(MAT *A)
MAT * swap_rows(MAT *, int, int, int, int)
VEC * v_map(double(*f)(), VEC *, VEC *)
VEC * v_lincomb(int, VEC **, Real *, VEC *)
double fin_double(FILE *fp, char *s, double low, double high)
VEC * v_star(VEC *, VEC *, VEC *)
int m_free_vars(MAT **,...)