#ifndef ITERHH
#define ITERHH
#include "sparse.h"
#ifdef ANSI_C
typedef
VEC *(*Fun_Ax)(
void
*,VEC *,VEC *);
#else
typedef
VEC *(*Fun_Ax)();
#endif
typedef
struct
Iter_data {
int
shared_x;
int
shared_b;
unsigned k;
int
limit;
int
steps;
Real eps;
VEC *x;
VEC *b;
Fun_Ax Ax;
void
*A_par;
Fun_Ax ATx;
void
*AT_par;
Fun_Ax Bx;
void
*B_par;
#ifdef ANSI_C
#ifdef PROTOTYPES_IN_STRUCT
void
(*info)(
struct
Iter_data *,
double
, VEC *,VEC *);
int
(*stop_crit)(
struct
Iter_data *,
double
, VEC *,VEC *);
#else
void
(*info)();
int
(*stop_crit)();
#endif /* PROTOTYPES_IN_STRUCT */
#else
void
(*info)();
int
(*stop_crit)();
#endif /* ANSI_C */
Real init_res;
} ITER;
#define INULL (ITER *)NULL
#ifdef ANSI_C
typedef
void
(*Fun_info)(ITER *,
double
, VEC *,VEC *);
#else
typedef
void
(*Fun_info)();
#endif
#ifdef ANSI_C
typedef
int
(*Fun_stp_crt)(ITER *,
double
, VEC *,VEC *);
#else
typedef
int
(*Fun_stp_crt)();
#endif
#define ITER_LIMIT_DEF 1000
#define ITER_EPS_DEF 1e-6
#define iter_Ax(ip,fun,fun_par) \
(ip->Ax=(Fun_Ax)(fun),ip->A_par=(
void
*)(fun_par),0)
#define iter_ATx(ip,fun,fun_par) \
(ip->ATx=(Fun_Ax)(fun),ip->AT_par=(
void
*)(fun_par),0)
#define iter_Bx(ip,fun,fun_par) \
(ip->Bx=(Fun_Ax)(fun),ip->B_par=(
void
*)(fun_par),0)
#define ITER_FREE(ip) (iter_free(ip), (ip)=(ITER *)NULL)
#ifdef ANSI_C
void
iter_std_info(ITER *ip,
double
nres,VEC *res,VEC *Bres);
int
iter_std_stop_crit(ITER *ip,
double
nres, VEC *res,VEC *Bres);
ITER *iter_get(
int
lenb,
int
lenx);
ITER *iter_resize(ITER *ip,
int
lenb,
int
lenx);
int
iter_free(ITER *ip);
void
iter_dump(
FILE
*fp,ITER *ip);
ITER *iter_copy(ITER *ip1, ITER *ip2);
ITER *iter_copy2(ITER *ip1,ITER *ip2);
SPMAT *iter_gen_sym(
int
n,
int
nrow);
SPMAT *iter_gen_nonsym(
int
m,
int
n,
int
nrow,
double
diag);
SPMAT *iter_gen_nonsym_posdef(
int
n,
int
nrow);
#else
void
iter_std_info();
int
iter_std_stop_crit();
ITER *iter_get();
int
iter_free();
ITER *iter_resize();
void
iter_dump();
ITER *iter_copy();
ITER *iter_copy2();
SPMAT *iter_gen_sym();
SPMAT *iter_gen_nonsym();
SPMAT *iter_gen_nonsym_posdef();
#endif
#ifdef ANSI_C
VEC *iter_cg(ITER *ip);
VEC *iter_cg1(ITER *ip);
VEC *iter_spcg(SPMAT *A,SPMAT *LLT,VEC *b,
double
eps,VEC *x,
int
limit,
int
*steps);
VEC *iter_cgs(ITER *ip,VEC *r0);
VEC *iter_spcgs(SPMAT *A,SPMAT *B,VEC *b,VEC *r0,
double
eps,VEC *x,
int
limit,
int
*steps);
VEC *iter_lsqr(ITER *ip);
VEC *iter_splsqr(SPMAT *A,VEC *b,
double
tol,VEC *x,
int
limit,
int
*steps);
VEC *iter_gmres(ITER *ip);
VEC *iter_spgmres(SPMAT *A,SPMAT *B,VEC *b,
double
tol,VEC *x,
int
k,
int
limit,
int
*steps);
MAT *iter_arnoldi_iref(ITER *ip,Real *h,MAT *Q,MAT *H);
MAT *iter_arnoldi(ITER *ip,Real *h,MAT *Q,MAT *H);
MAT *iter_sparnoldi(SPMAT *A,VEC *x0,
int
k,Real *h,MAT *Q,MAT *H);
VEC *iter_mgcr(ITER *ip);
VEC *iter_spmgcr(SPMAT *A,SPMAT *B,VEC *b,
double
tol,VEC *x,
int
k,
int
limit,
int
*steps);
void
iter_lanczos(ITER *ip,VEC *a,VEC *b,Real *beta2,MAT *Q);
void
iter_splanczos(SPMAT *A,
int
m,VEC *x0,VEC *a,VEC *b,Real *beta2,
MAT *Q);
VEC *iter_lanczos2(ITER *ip,VEC *evals,VEC *err_est);
VEC *iter_splanczos2(SPMAT *A,
int
m,VEC *x0,VEC *evals,VEC *err_est);
VEC *iter_cgne(ITER *ip);
VEC *iter_spcgne(SPMAT *A,SPMAT *B,VEC *b,
double
eps,VEC *x,
int
limit,
int
*steps);
#else
VEC *iter_cg();
VEC *iter_cg1();
VEC *iter_spcg();
VEC *iter_cgs();
VEC *iter_spcgs();
VEC *iter_lsqr();
VEC *iter_splsqr();
VEC *iter_gmres();
VEC *iter_spgmres();
MAT *iter_arnoldi_iref();
MAT *iter_arnoldi();
MAT *iter_sparnoldi();
VEC *iter_mgcr();
VEC *iter_spmgcr();
void
iter_lanczos();
void
iter_splanczos();
VEC *iter_lanczos2();
VEC *iter_splanczos2();
VEC *iter_cgne();
VEC *iter_spcgne();
#endif
#endif /* ITERHH */