Subversion Repositories slepc-dev

Rev

Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1619 slepc 1
/*
2110 jroman 2
  Method: General Davidson Method (includes GD and JD)
1619 slepc 3
 
4
  References:
5
    - Ernest R. Davidson. Super-matrix methods. Computer Physics Communications,
6
      53:49–60, May 1989.
7
 
2110 jroman 8
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
9
   SLEPc - Scalable Library for Eigenvalue Problem Computations
2116 eromero 10
   Copyright (c) 2002-2010, Universidad Politecnica de Valencia, Spain
1619 slepc 11
 
2110 jroman 12
   This file is part of SLEPc.
13
 
14
   SLEPc is free software: you can redistribute it and/or modify it under  the
15
   terms of version 3 of the GNU Lesser General Public License as published by
16
   the Free Software Foundation.
1619 slepc 17
 
2110 jroman 18
   SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
19
   WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
20
   FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
21
   more details.
1619 slepc 22
 
2110 jroman 23
   You  should have received a copy of the GNU Lesser General  Public  License
24
   along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
25
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1619 slepc 26
*/
27
 
28
 
29
/*
30
   Dashboard struct: contains the methods that will be employed and the tunning
31
   options.
32
*/
33
 
34
#include "petsc.h"
35
#include "private/epsimpl.h"
1873 eromero 36
#include "private/stimpl.h"
1619 slepc 37
 
38
 
39
typedef struct _dvdFunctionList {
2021 eromero 40
  PetscErrorCode (*f)(void*);
1619 slepc 41
  void *d;
42
  struct _dvdFunctionList *next;
43
} dvdFunctionList;
1735 eromero 44
 
45
typedef PetscInt MatType_t;
46
#define DVD_MAT_HERMITIAN (1<<1)
47
#define DVD_MAT_NEG_DEF (1<<2)
48
#define DVD_MAT_POS_DEF (1<<3)
49
#define DVD_MAT_SINGULAR (1<<4)
50
#define DVD_MAT_COMPLEX (1<<5)
51
#define DVD_MAT_IMPLICIT (1<<6)
52
#define DVD_MAT_IDENTITY (1<<7)
53
#define DVD_MAT_DIAG (1<<8)
54
#define DVD_MAT_TRIANG (1<<9)
1747 eromero 55
#define DVD_MAT_UTRIANG (1<<9)
56
#define DVD_MAT_LTRIANG (1<<10)
57
#define DVD_MAT_UNITARY (1<<11)
58
 
1756 eromero 59
typedef PetscInt EPType_t;
1960 eromero 60
#define DVD_EP_STD (1<<1)
1756 eromero 61
#define DVD_EP_HERMITIAN (1<<2)
62
 
63
#define DVD_IS(T,P) ((T) & (P))
64
#define DVD_ISNOT(T,P) (((T) & (P)) ^ (P))
65
 
1883 eromero 66
typedef enum {
67
  DVD_HARM_NONE,
68
  DVD_HARM_RR,
69
  DVD_HARM_RRR,
70
  DVD_HARM_REIGS,
71
  DVD_HARM_LEIGS
72
} HarmType_t;
1795 eromero 73
 
1883 eromero 74
typedef enum {
75
  DVD_INITV_CLASSIC,
76
  DVD_INITV_KRYLOV
77
} InitType_t;
1795 eromero 78
 
1980 eromero 79
typedef enum {
80
  DVD_PROJ_KBXX,
81
  DVD_PROJ_KBXY,
82
  DVD_PROJ_KBXZ,
83
  DVD_PROJ_KBXZY
84
} ProjType_t;
1883 eromero 85
 
2012 eromero 86
typedef enum {
87
    DVD_MT_IDENTITY,/* without transformation */
88
    DVD_MT_pX,       /* using the projected problem eigenvectors */
89
    DVD_MT_ORTHO    /* using an orthonormal transformation */
90
} MT_type_t;
91
 
92
typedef enum {
93
    DVD_ORTHOV_NONE,/* V isn't orthonormalized */
94
    DVD_ORTHOV_I,   /* V is orthonormalized */    
95
    DVD_ORTHOV_B    /* V is B-orthonormalized */
96
} orthoV_type_t;
97
 
98
 
1619 slepc 99
typedef struct _dvdDashboard {
100
  /**** Function steps ****/
101
  /* Initialize V */
2021 eromero 102
  PetscErrorCode (*initV)(struct _dvdDashboard*);
1619 slepc 103
  void *initV_data;
104
 
105
  /* Find the approximate eigenpairs from V */
2021 eromero 106
  PetscErrorCode (*calcPairs)(struct _dvdDashboard*);
1619 slepc 107
  void *calcPairs_data;
108
 
2018 eromero 109
  /* Eigenpair test for convergence */
1619 slepc 110
  PetscTruth (*testConv)(struct _dvdDashboard*, PetscScalar eigvr,
1960 eromero 111
       PetscScalar eigvi, PetscReal res, PetscReal *error);
1619 slepc 112
  void *testConv_data;
113
 
114
  /* Number of converged eigenpairs */
115
  PetscInt nconv;
116
 
1735 eromero 117
  /* Number of pairs ready to converge */
118
  PetscInt npreconv;
119
 
1619 slepc 120
  /* Improve the selected eigenpairs */
2021 eromero 121
  PetscErrorCode (*improveX)(struct _dvdDashboard*, Vec *D, PetscInt max_size_D,
1735 eromero 122
                       PetscInt r_s, PetscInt r_e, PetscInt *size_D);
1619 slepc 123
  void *improveX_data;
124
 
125
  /* Check for restarting */
126
  PetscTruth (*isRestarting)(struct _dvdDashboard*);
127
  void *isRestarting_data;
128
 
129
  /* Perform restarting */
2021 eromero 130
  PetscErrorCode (*restartV)(struct _dvdDashboard*);
1619 slepc 131
  void *restartV_data;
132
 
133
  /* Update V */
2021 eromero 134
  PetscErrorCode (*updateV)(struct _dvdDashboard*);
1619 slepc 135
  void *updateV_data;
136
 
137
  /**** Problem specification ****/
138
  Mat A, B;         /* Problem matrices */
1747 eromero 139
  MatType_t sA, sB; /* Matrix specifications */
1756 eromero 140
  EPType_t sEP;     /* Problem specifications */
1619 slepc 141
  PetscInt nev;     /* number of eigenpairs */
142
  EPSWhich which;   /* spectrum selection */
143
  PetscTruth
144
    withTarget;     /* if there is a target */
145
  PetscScalar
1883 eromero 146
    target[2];         /* target value */
1619 slepc 147
  PetscReal tol;    /* tolerance */
1795 eromero 148
  PetscTruth
149
    correctXnorm;   /* if true, tol < |r|/|x| */
1619 slepc 150
 
151
  /**** Subspaces specification ****/
152
  Vec *V,           /* searching subspace */
1795 eromero 153
    *W,             /* testing subspace */
1751 eromero 154
    *cX,            /* converged right eigenvectors */
155
    *cY,            /* converged left eigenvectors */
1829 eromero 156
    *BcX,           /* basis of B*cX */
1735 eromero 157
    *AV,            /* A*V */
158
    *real_AV,       /* original A*V space */
159
    *BV,            /* B*V */
160
    *real_BV;       /* original B*V space */
1619 slepc 161
  PetscInt size_V,  /* size of V */
1735 eromero 162
    size_AV,        /* size of AV */
163
    size_BV,        /* size of BV */
1619 slepc 164
    size_cX,        /* size of cX */
1751 eromero 165
    size_cY,        /* size of cY */
1735 eromero 166
    size_D,         /* active vectors */
1619 slepc 167
    max_size_V,     /* max size of V */
168
    max_size_X,     /* max size of X */
1735 eromero 169
    max_size_AV,    /* max size of AV */
170
    max_size_BV;    /* max size of BV */
1805 eromero 171
  EPS eps;          /* Connection to SLEPc */
1619 slepc 172
 
173
  /**** Auxiliary space ****/
174
  Vec *auxV;        /* auxiliary vectors */
175
  PetscScalar
176
    *auxS;          /* auxiliary scalars */
177
  PetscInt
178
    size_auxV,      /* max size of auxV */
179
    size_auxS;      /* max size of auxS */
180
 
181
  /**** Eigenvalues and errors ****/
182
  PetscScalar
183
    *ceigr, *ceigi, /* converged eigenvalues */
184
    *eigr, *eigi;   /* current eigenvalues */
185
  PetscReal
1735 eromero 186
    *nR,            /* residual norm */
1764 eromero 187
    *nX,            /* X norm */
1735 eromero 188
    *errest;        /* relative error eigenpairs */
1619 slepc 189
 
190
  /**** Shared function and variables ****/
2021 eromero 191
  PetscErrorCode (*e_Vchanged)(struct _dvdDashboard*, PetscInt s_imm,
1619 slepc 192
                         PetscInt e_imm, PetscInt s_new, PetscInt e_new);
193
  void *e_Vchanged_data;
194
 
2021 eromero 195
  PetscErrorCode (*calcpairs_residual)(struct _dvdDashboard*, PetscInt s, PetscInt e,
1751 eromero 196
                                 Vec *R, PetscScalar *auxS, Vec auxV);
2021 eromero 197
  PetscErrorCode (*calcpairs_selectPairs)(struct _dvdDashboard*, PetscInt n);
1736 eromero 198
  void *calcpairs_residual_data;
2021 eromero 199
  PetscErrorCode (*calcpairs_X)(struct _dvdDashboard*, PetscInt s, PetscInt e,
1735 eromero 200
                          Vec *X);
2021 eromero 201
  PetscErrorCode (*calcpairs_Y)(struct _dvdDashboard*, PetscInt s, PetscInt e,
1809 eromero 202
                          Vec *Y);
1736 eromero 203
  PetscErrorCode (*improvex_precond)(struct _dvdDashboard*, PetscInt i, Vec x,
204
                  Vec Px);
205
  void *improvex_precond_data;
1960 eromero 206
  PetscErrorCode (*improvex_jd_proj_uv)(struct _dvdDashboard*, PetscInt i_s,
207
                                        PetscInt i_e, Vec **u, Vec **v,
1965 eromero 208
                                        Vec **kr, Vec **auxV_,
209
                                        PetscScalar *theta,
210
                                        PetscScalar *thetai,
211
                                        PetscScalar *pX, PetscScalar *pY,
212
                                        PetscInt ld);
1867 eromero 213
  PetscErrorCode (*improvex_jd_lit)(struct _dvdDashboard*, PetscInt i,
1960 eromero 214
                                    PetscScalar* theta, PetscScalar* thetai,
215
                                    PetscInt *maxits, PetscReal *tol);
1795 eromero 216
  PetscErrorCode (*calcpairs_W)(struct _dvdDashboard*);
217
  void *calcpairs_W_data;
218
  PetscErrorCode (*calcpairs_proj_trans)(struct _dvdDashboard*);
1883 eromero 219
  PetscErrorCode (*calcpairs_eigs_trans)(struct _dvdDashboard*);
220
  PetscErrorCode (*calcpairs_proj_res)(struct _dvdDashboard*, PetscInt r_s,
221
                  PetscInt r_e, Vec *R);
2018 eromero 222
  PetscErrorCode (*preTestConv)(struct _dvdDashboard*, PetscInt s, PetscInt pre,
223
                                PetscInt e, Vec *auxV, PetscScalar *auxS,
224
                                      PetscInt *nConv);
1619 slepc 225
 
2021 eromero 226
  PetscErrorCode (*e_newIteration)(struct _dvdDashboard*);
1619 slepc 227
  void *e_newIteration_data;
228
 
1751 eromero 229
  IP ipI;
1795 eromero 230
  IP ipV,           /* orthogonal routine options for V subspace */
231
    ipW;            /* orthogonal routine options for W subspace */
1751 eromero 232
 
1619 slepc 233
  dvdFunctionList
1883 eromero 234
    *startList,     /* starting list */
235
    *endList,       /* ending list */
1619 slepc 236
    *destroyList;   /* destructor list */
237
 
1735 eromero 238
  PetscScalar *H,   /* Projected problem matrix A*/
239
    *real_H,        /* original H */
240
    *G,             /* Projected problem matrix B*/
241
    *real_G,        /* original G */
1750 eromero 242
    *pX,            /* projected problem right eigenvectors */
243
    *pY,            /* projected problem left eigenvectors */
1795 eromero 244
    *MTX,           /* right transformation matrix */
245
    *MTY,           /* left transformation matrix */
1750 eromero 246
    *S,             /* first Schur matrix, S = pY'*H*pX */
1756 eromero 247
    *T,             /* second Schur matrix, T = pY'*G*pX */
248
    *cS,            /* first Schur matrix of converged pairs */
249
    *cT;            /* second Schur matrix of converged pairs */
1750 eromero 250
  MatType_t
251
    pX_type,        /* pX properties */
252
    pY_type,        /* pY properties */
1747 eromero 253
    sH,             /* H properties */
254
    sG;             /* G properties */
1735 eromero 255
  PetscInt ldH,     /* leading dimension of H */
1750 eromero 256
    ldpX,           /* leading dimension of pX */
257
    ldpY,           /* leading dimension of pY */
1795 eromero 258
    ldMTX,          /* leading dimension of MTX */
259
    ldMTY,          /* leading dimension of MTY */
1750 eromero 260
    ldS,            /* leading dimension of S */
261
    ldT,            /* leading dimension of T */
1756 eromero 262
    ldcS,           /* leading dimension of cS */
263
    ldcT,           /* leading dimension of cT */
1742 eromero 264
    size_H,         /* rows and columns in H */
265
    size_G,         /* rows and columns in G */
266
    size_MT;        /* rows in MT */
1619 slepc 267
 
1735 eromero 268
  PetscInt V_imm_s,
269
    V_imm_e,        /* unchanged V columns, V_imm_s:V_imm_e-1 */
270
    V_tra_s,
271
    V_tra_e,        /* V(V_tra_e:) = V*MT(V_tra_s:V_tra_e-1) */
272
    V_new_s,
273
    V_new_e;        /* added to V the columns V_new_s:V_new_e */
1975 eromero 274
 
2012 eromero 275
  MT_type_t MT_type;
276
  orthoV_type_t orthoV_type;
277
 
1975 eromero 278
  PetscRandom rand; /* random seed */
1992 eromero 279
  void* prof_data;  /* profiler data */
1619 slepc 280
} dvdDashboard;
281
 
282
#define DVD_FL_ADD(list, fun) { \
283
  dvdFunctionList *fl=(list); \
284
  PetscErrorCode ierr; \
285
  ierr = PetscMalloc(sizeof(dvdFunctionList), &(list)); CHKERRQ(ierr); \
2021 eromero 286
  (list)->f = (PetscErrorCode(*)(void*))(fun); \
1619 slepc 287
  (list)->next = fl; }
288
 
1883 eromero 289
#define DVD_FL_CALL(list, arg0) { \
1619 slepc 290
  dvdFunctionList *fl; \
1883 eromero 291
  for(fl=(list); fl; fl=fl->next) (*(dvdCallback)fl->f)((arg0)); }
1619 slepc 292
 
293
#define DVD_FL_DEL(list) { \
294
  dvdFunctionList *fl=(list), *oldfl; \
295
  PetscErrorCode ierr; \
296
  while(fl) { \
297
    oldfl = fl; fl = fl->next; ierr = PetscFree(oldfl); CHKERRQ(ierr); }}
298
 
299
/*
300
  The blackboard configuration structure: saves information about the memory
301
  and other requirements
302
*/
303
typedef struct {
2047 eromero 304
  PetscInt max_size_V,  /* max size of the searching subspace */
1619 slepc 305
    max_size_X,         /* max size of X */
2047 eromero 306
    size_V,             /* real size of V */
1619 slepc 307
    max_size_oldX,      /* max size of oldX */
308
    max_size_auxV,      /* max size of auxiliary vecs */
309
    max_size_auxS,      /* max size of auxiliary scalars */
1966 eromero 310
    max_nev,            /* max number of converged pairs */
1619 slepc 311
    own_vecs,           /* number of global vecs */
312
    own_scalars;        /* number of local scalars */
313
  Vec *free_vecs;       /* free global vectors */
314
  PetscScalar
315
    *free_scalars;      /* free scalars */
1734 eromero 316
  PetscInt state;       /* method states:
1619 slepc 317
                            0: preconfiguring
318
                            1: configuring
319
                            2: running
320
                        */
321
} dvdBlackboard;
322
 
1734 eromero 323
#define DVD_STATE_PRECONF 0
324
#define DVD_STATE_CONF 1
325
#define DVD_STATE_RUN 2
1619 slepc 326
 
327
/* Shared types */
1736 eromero 328
typedef void* dvdPrecondData; // DEPRECATED!!
329
typedef PetscErrorCode (*dvdPrecond)(dvdDashboard*, PetscInt i, Vec x, Vec Px);
2021 eromero 330
typedef PetscErrorCode (*dvdCallback)(dvdDashboard*);
331
typedef PetscErrorCode (*e_Vchanged_type)(dvdDashboard*, PetscInt s_imm,
1619 slepc 332
                         PetscInt e_imm, PetscInt s_new, PetscInt e_new);
333
typedef PetscTruth (*isRestarting_type)(dvdDashboard*);
2021 eromero 334
typedef PetscErrorCode (*e_newIteration_type)(dvdDashboard*);
335
typedef PetscErrorCode (*improveX_type)(dvdDashboard*, Vec *D, PetscInt max_size_D,
1735 eromero 336
                                  PetscInt r_s, PetscInt r_e, PetscInt *size_D);
1619 slepc 337
 
1753 eromero 338
/* Structures for blas */
339
typedef PetscErrorCode (*DvdReductionPostF)(PetscScalar*,PetscInt,void*);
340
typedef struct {
341
  PetscScalar
342
    *out;               /* final vector */
343
  PetscInt
344
    size_out;           /* size of out */
345
  DvdReductionPostF
346
    f;                  /* function called after the reduction */
347
  void *ptr;
348
} DvdReductionChunk;  
349
 
350
typedef struct {
351
  PetscScalar
352
    *in,                /* vector to sum-up with more nodes */
353
    *out;               /* final vector */
354
  PetscInt size_in,     /* size of in */
355
    max_size_in;        /* max size of in */
356
  DvdReductionChunk
357
    *ops;               /* vector of reduction operations */
358
  PetscInt
359
    size_ops,           /* size of ops */
360
    max_size_ops;       /* max size of ops */
361
  MPI_Comm comm;        /* MPI communicator */
362
} DvdReduction;
363
 
364
typedef struct {
365
  PetscInt i0, i1, i2, ld, s0, e0, s1, e1;
366
  PetscScalar *M;
367
} DvdMult_copy_func;
368
 
1619 slepc 369
/* Routines for initV step */
2021 eromero 370
PetscErrorCode dvd_initV_classic(dvdDashboard *d, dvdBlackboard *b, PetscInt k);
371
PetscErrorCode dvd_initV_user(dvdDashboard *d, dvdBlackboard *b, Vec *userV,
1875 eromero 372
                        PetscInt size_userV, PetscInt k);
2021 eromero 373
PetscErrorCode dvd_initV_krylov(dvdDashboard *d, dvdBlackboard *b, PetscInt k);
1619 slepc 374
 
375
/* Routines for calcPairs step */
2021 eromero 376
PetscErrorCode dvd_calcpairs_rr(dvdDashboard *d, dvdBlackboard *b);
377
PetscErrorCode dvd_calcpairs_qz(dvdDashboard *d, dvdBlackboard *b, IP ip);
1619 slepc 378
 
379
/* Routines for improveX step */
2021 eromero 380
PetscErrorCode dvd_improvex_jd(dvdDashboard *d, dvdBlackboard *b, KSP ksp,
1965 eromero 381
                         PetscInt max_bs);
2021 eromero 382
PetscErrorCode dvd_improvex_jd_proj_uv(dvdDashboard *d, dvdBlackboard *b,
1980 eromero 383
                                 ProjType_t p);
2021 eromero 384
PetscErrorCode dvd_improvex_jd_lit_const(dvdDashboard *d, dvdBlackboard *b,
1883 eromero 385
                                   PetscInt maxits, PetscReal tol,
386
                                   PetscReal fix);
1619 slepc 387
 
388
/* Routines for testConv step */
2021 eromero 389
PetscErrorCode dvd_testconv_basic(dvdDashboard *d, dvdBlackboard *b);
390
PetscErrorCode dvd_testconv_slepc(dvdDashboard *d, dvdBlackboard *b);
1619 slepc 391
 
392
/* Routines for management of V */
2021 eromero 393
PetscErrorCode dvd_managementV_basic(dvdDashboard *d, dvdBlackboard *b,
2023 eromero 394
                                     PetscInt bs, PetscInt max_size_V,
395
                                     PetscInt mpd, PetscInt min_size_V,
2037 eromero 396
                                     PetscInt plusk, PetscTruth harm,
397
                                     PetscTruth allResiduals);
1619 slepc 398
 
399
/* Some utilities */
1764 eromero 400
PetscErrorCode dvd_static_precond_PC(dvdDashboard *d, dvdBlackboard *b, PC pc);
1736 eromero 401
PetscErrorCode dvd_jacobi_precond(dvdDashboard *d, dvdBlackboard *b);
1992 eromero 402
PetscErrorCode dvd_profiler(dvdDashboard *d, dvdBlackboard *b);
403
PetscErrorCode dvd_prof_init();
1795 eromero 404
PetscErrorCode dvd_harm_conf(dvdDashboard *d, dvdBlackboard *b,
405
                             HarmType_t mode, PetscTruth fixedTarget,
406
                             PetscScalar t);
1619 slepc 407
 
408
/* Methods */
409
PetscErrorCode dvd_schm_basic_preconf(dvdDashboard *d, dvdBlackboard *b,
2023 eromero 410
  PetscInt max_size_V, PetscInt mpd, PetscInt min_size_V, PetscInt bs,
411
  PetscInt ini_size_V, Vec *initV, PetscInt size_initV, PetscInt plusk, PC pc,
2037 eromero 412
  HarmType_t harmMode, KSP ksp, InitType_t init, PetscTruth allResiduals);
1619 slepc 413
PetscErrorCode dvd_schm_basic_conf(dvdDashboard *d, dvdBlackboard *b,
2023 eromero 414
  PetscInt max_size_V, PetscInt mpd, PetscInt min_size_V, PetscInt bs,
415
  PetscInt ini_size_V, Vec *initV, PetscInt size_initV, PetscInt plusk, PC pc,
416
  IP ip, HarmType_t harmMode, PetscTruth fixedTarget, PetscScalar t, KSP ksp,
2037 eromero 417
  PetscReal fix, InitType_t init, PetscTruth allResiduals);
1619 slepc 418
 
419
/* BLAS routines */
1745 eromero 420
PetscErrorCode dvd_blas_prof_init();
1619 slepc 421
PetscErrorCode SlepcDenseMatProd(PetscScalar *C, PetscInt _ldC, PetscScalar b,
422
  PetscScalar a,
423
  const PetscScalar *A, PetscInt _ldA, PetscInt rA, PetscInt cA, PetscTruth At,
424
  const PetscScalar *B, PetscInt _ldB, PetscInt rB, PetscInt cB, PetscTruth Bt);
1747 eromero 425
PetscErrorCode SlepcDenseMatProdTriang(
426
  PetscScalar *C, MatType_t sC, PetscInt ldC,
427
  const PetscScalar *A, MatType_t sA, PetscInt ldA, PetscInt rA, PetscInt cA,
428
  PetscTruth At,
429
  const PetscScalar *B, MatType_t sB, PetscInt ldB, PetscInt rB, PetscInt cB,
430
  PetscTruth Bt);
1735 eromero 431
PetscErrorCode SlepcDenseMatInvProd(
432
  PetscScalar *A, PetscInt _ldA, PetscInt dimA,
433
  PetscScalar *B, PetscInt _ldB, PetscInt rB, PetscInt cB, PetscInt *auxI);
1750 eromero 434
PetscErrorCode SlepcDenseNorm(PetscScalar *A, PetscInt ldA, PetscInt _rA,
1965 eromero 435
                              PetscInt cA, PetscScalar *eigi);
1742 eromero 436
PetscErrorCode SlepcDenseOrth(PetscScalar *A, PetscInt _ldA, PetscInt _rA,
437
                              PetscInt _cA, PetscScalar *auxS, PetscInt _lauxS,
438
                              PetscInt *ncA);
439
PetscErrorCode SlepcDenseCopy(PetscScalar *Y, PetscInt ldY, PetscScalar *X,
440
                              PetscInt ldX, PetscInt rX, PetscInt cX);
1752 eromero 441
PetscErrorCode SlepcDenseCopyTriang(PetscScalar *Y, MatType_t sY, PetscInt ldY,
442
                                    PetscScalar *X, MatType_t sX, PetscInt ldX,
443
                                    PetscInt rX, PetscInt cX);
1675 slepc 444
PetscErrorCode SlepcUpdateVectorsZ(Vec *Y, PetscScalar beta, PetscScalar alpha,
445
  Vec *X, PetscInt cX, const PetscScalar *M, PetscInt ldM, PetscInt rM,
446
  PetscInt cM);
1960 eromero 447
PetscErrorCode SlepcUpdateVectorsS(Vec *Y, PetscInt dY, PetscScalar beta,
448
  PetscScalar alpha, Vec *X, PetscInt cX, PetscInt dX, const PetscScalar *M,
449
  PetscInt ldM, PetscInt rM, PetscInt cM);
1965 eromero 450
PetscErrorCode SlepcUpdateVectorsD(Vec *X, PetscInt cX, PetscScalar alpha,
451
  const PetscScalar *M, PetscInt ldM, PetscInt rM, PetscInt cM,
452
  PetscScalar *work, PetscInt lwork);
1747 eromero 453
PetscErrorCode VecsMult(PetscScalar *M, MatType_t sM, PetscInt ldM,
1634 slepc 454
                        Vec *U, PetscInt sU, PetscInt eU,
455
                        Vec *V, PetscInt sV, PetscInt eV,
1640 slepc 456
                        PetscScalar *workS0, PetscScalar *workS1);
1753 eromero 457
PetscErrorCode VecsMultS(PetscScalar *M, MatType_t sM, PetscInt ldM,
458
                         Vec *U, PetscInt sU, PetscInt eU,
459
                         Vec *V, PetscInt sV, PetscInt eV, DvdReduction *r,
460
                         DvdMult_copy_func *sr);
1808 eromero 461
PetscErrorCode VecsMultIc(PetscScalar *M, MatType_t sM, PetscInt ldM,
462
                          PetscInt rM, PetscInt cM, Vec V);
1795 eromero 463
PetscErrorCode VecsMultIb(PetscScalar *M, MatType_t sM, PetscInt ldM,
464
                          PetscInt rM, PetscInt cM, PetscScalar *auxS,
465
                          Vec V);
466
PetscErrorCode VecsMultIa(PetscScalar *M, MatType_t sM, PetscInt ldM,
467
                          Vec *U, PetscInt sU, PetscInt eU,
468
                          Vec *V, PetscInt sV, PetscInt eV);
1753 eromero 469
PetscErrorCode SlepcAllReduceSumBegin(DvdReductionChunk *ops,
470
                                      PetscInt max_size_ops,
471
                                      PetscScalar *in, PetscScalar *out,
472
                                      PetscInt max_size_in, DvdReduction *r,
473
                                      MPI_Comm comm);
474
PetscErrorCode SlepcAllReduceSum(DvdReduction *r, PetscInt size_in,
475
                                 DvdReductionPostF f, void *ptr,
476
                                 PetscScalar **in);
477
PetscErrorCode SlepcAllReduceSumEnd(DvdReduction *r);
1989 eromero 478
PetscErrorCode dvd_orthV(IP ip, Vec *DS, PetscInt size_DS, Vec *cX,
479
                         PetscInt size_cX, Vec *V, PetscInt V_new_s,
480
                         PetscInt V_new_e, PetscScalar *auxS, Vec auxV,
481
                         PetscRandom rand);
1968 eromero 482
PetscErrorCode dvd_compute_eigenvectors(PetscInt n_, PetscScalar *S,
483
  PetscInt ldS_, PetscScalar *T, PetscInt ldT_, PetscScalar *pX,
484
  PetscInt ldpX_, PetscScalar *pY, PetscInt ldpY_, PetscScalar *auxS,
485
  PetscInt size_auxS, PetscTruth doProd);
2034 eromero 486
PetscErrorCode dvd_compute_eigenvalues(PetscInt n, PetscScalar *S,
487
  PetscInt ldS, PetscScalar *T, PetscInt ldT, PetscScalar *eigr,
488
  PetscScalar *eigi);
1976 eromero 489
 
490
/* SLEPc interface routines */
491
PetscErrorCode SLEPcNotImplemented();
1982 eromero 492
PetscErrorCode EPSCreate_DAVIDSON(EPS eps);
1992 eromero 493
PetscErrorCode EPSDestroy_DAVIDSON(EPS eps);
1976 eromero 494
PetscErrorCode EPSSetUp_DAVIDSON(EPS eps);
495
PetscErrorCode EPSSolve_DAVIDSON(EPS eps);
496
PetscErrorCode EPSComputeVectors_QZ(EPS eps);
1980 eromero 497
PetscErrorCode EPSDAVIDSONSetKrylovStart_DAVIDSON(EPS eps,PetscTruth krylovstart);
498
PetscErrorCode EPSDAVIDSONGetKrylovStart_DAVIDSON(EPS eps,PetscTruth *krylovstart);
499
PetscErrorCode EPSDAVIDSONSetBlockSize_DAVIDSON(EPS eps,PetscInt blocksize);
500
PetscErrorCode EPSDAVIDSONGetBlockSize_DAVIDSON(EPS eps,PetscInt *blocksize);
501
PetscErrorCode EPSDAVIDSONSetRestart_DAVIDSON(EPS eps,PetscInt minv,PetscInt plusk);
502
PetscErrorCode EPSDAVIDSONGetRestart_DAVIDSON(EPS eps,PetscInt *minv,PetscInt *plusk);
503
PetscErrorCode EPSDAVIDSONGetInitialSize_DAVIDSON(EPS eps,PetscInt *initialsize);
504
PetscErrorCode EPSDAVIDSONSetInitialSize_DAVIDSON(EPS eps,PetscInt initialsize);
1995 eromero 505
PetscErrorCode EPSDAVIDSONGetFix_DAVIDSON(EPS eps,PetscReal *fix);
506
PetscErrorCode EPSDAVIDSONSetFix_DAVIDSON(EPS eps,PetscReal fix);
1976 eromero 507
 
508
typedef struct {
1980 eromero 509
  /**** Solver options ****/
510
  PetscInt blocksize,     /* block size */
511
    initialsize,          /* initial size of V */
512
    minv,                 /* size of V after restarting */
513
    plusk;                /* keep plusk eigenvectors from the last iteration */
514
  PetscTruth ipB;         /* truth if V'B*V=I */
515
  PetscInt   method;      /* method for improving the approximate solution */
516
  PetscReal  fix;         /* the fix parameter */
517
  PetscTruth krylovstart; /* true if the starting subspace is a Krylov basis */
518
 
1976 eromero 519
  /**** Solver data ****/
520
  dvdDashboard ddb;
521
 
522
  /**** Things to destroy ****/
523
  PetscScalar *wS;
1992 eromero 524
  Vec         *wV;
525
  PetscInt    size_wV;
2015 eromero 526
  PC          pc;         /* pc extracted from st->ksp */
1985 eromero 527
} EPS_DAVIDSON;
1976 eromero 528