LoginSignup
0
1

More than 5 years have passed since last update.

ADDA > iterative.c > ITER_FUNC(BCGS2) / function call

Last updated at Posted at 2016-11-23
My_Environment
Ubuntu 14.04 LTS Japanese Remix
on VMWare Fusion v8.5.2 (4635224)
on OS X El Captian v10.11.4

GNU bash, version 4.3.11(1)-release

gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4 
(also for g++)
ADDA v.1.3b6

This article is related to ADDA (light scattering simulator based on the discrete dipole approximation).

In the source files, I found itertive.c.
https://github.com/adda-team/adda/blob/master/src/iterative.c

ITER_FUNC(BCGS2)

In the iterative.c, I found the followings:

ITER_FUNC(BCGS2);
ITER_FUNC(BiCG_CS);
ITER_FUNC(BiCGStab);
ITER_FUNC(CGNR);
ITER_FUNC(CSYM);
ITER_FUNC(QMR_CS);
ITER_FUNC(QMR_CS_2);

The ITER_FUNC is a macro defined as followings

#define ITER_FUNC(name) static void name(const enum phase ph)

I am not sure, but this seems a means to show explicitly the groups of iterative solvers, rather than to name using prefix (e.g. ITER_BCGS2(), ITER_BiGC_CS() etc).

This also enforces to use enum elements (e.g. BCGS2, BiGC_CS), which are used in other parts of the code.

function call

It seems that functions defined using ITER_FUNC() are called through:

iterative.c
static const struct iter_params_struct params[]={
    {IT_BCGS2,15000,2,1,BCGS2},
    {IT_BICG_CS,50000,1,0,BiCG_CS},
    {IT_BICGSTAB,30000,3,3,BiCGStab},
    {IT_CGNR,10,1,0,CGNR},
    {IT_CSYM,10,6,2,CSYM},
    {IT_QMR_CS,50000,8,3,QMR_CS},
    {IT_QMR_CS_2,50000,5,2,QMR_CS_2}
...
};

where struct iter_params_struct are defined as

iterative.c
struct iter_params_struct {
    enum iter meth;   // identifier
    int mc;           // maximum allowed number of iterations without residual decrease
    int sc_N;         // number of additional scalars to describe the state
    int vec_N;        // number of additional vectors to describe the state
    void (*func)(const enum phase); // pointer to implementation of the iterative solver
};
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1