Subversion Repositories slepc-dev

Rev

Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1376 slepc 1
/*
2
       This file implements a wrapper to the BLZPACK package
6 dsic.upv.es!jroman 3
 
1376 slepc 4
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1672 slepc 5
   SLEPc - Scalable Library for Eigenvalue Problem Computations
6
   Copyright (c) 2002-2009, Universidad Politecnica de Valencia, Spain
1376 slepc 7
 
1672 slepc 8
   This file is part of SLEPc.
9
 
10
   SLEPc is free software: you can redistribute it and/or modify it under  the
11
   terms of version 3 of the GNU Lesser General Public License as published by
12
   the Free Software Foundation.
13
 
14
   SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
15
   WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
16
   FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
17
   more details.
18
 
19
   You  should have received a copy of the GNU Lesser General  Public  License
20
   along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
1376 slepc 21
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
6 dsic.upv.es!jroman 22
*/
1376 slepc 23
 
1705 jroman 24
#include "src/eps/impls/external/blzpack/blzpackp.h"   /*I "slepceps.h" I*/
1696 slepc 25
#include "private/stimpl.h"
6 dsic.upv.es!jroman 26
 
114 dsic.upv.es!antodo 27
const char* blzpack_error[33] = {
28
  "",
29
  "illegal data, LFLAG ",
30
  "illegal data, dimension of (U), (V), (X) ",
31
  "illegal data, leading dimension of (U), (V), (X) ",
32
  "illegal data, leading dimension of (EIG) ",
33
  "illegal data, number of required eigenpairs ",
34
  "illegal data, Lanczos algorithm block size ",
35
  "illegal data, maximum number of steps ",
36
  "illegal data, number of starting vectors ",
37
  "illegal data, number of eigenpairs provided ",
38
  "illegal data, problem type flag ",
39
  "illegal data, spectrum slicing flag ",
40
  "illegal data, eigenvectors purification flag ",
41
  "illegal data, level of output ",
42
  "illegal data, output file unit ",
43
  "illegal data, LCOMM (MPI or PVM) ",
44
  "illegal data, dimension of ISTOR ",
45
  "illegal data, convergence threshold ",
46
  "illegal data, dimension of RSTOR ",
47
  "illegal data on at least one PE ",
48
  "ISTOR(3:14) must be equal on all PEs ",
49
  "RSTOR(1:3) must be equal on all PEs ",
50
  "not enough space in ISTOR to start eigensolution ",
51
  "not enough space in RSTOR to start eigensolution ",
52
  "illegal data, number of negative eigenvalues ",
53
  "illegal data, entries of V ",
54
  "illegal data, entries of X ",
55
  "failure in computational subinterval ",
56
  "file I/O error, blzpack.__.BQ ",
57
  "file I/O error, blzpack.__.BX ",
58
  "file I/O error, blzpack.__.Q ",
59
  "file I/O error, blzpack.__.X ",
60
  "parallel interface error "
61
};
62
 
6 dsic.upv.es!jroman 63
#undef __FUNCT__  
64
#define __FUNCT__ "EPSSetUp_BLZPACK"
476 dsic.upv.es!antodo 65
PetscErrorCode EPSSetUp_BLZPACK(EPS eps)
6 dsic.upv.es!jroman 66
{
476 dsic.upv.es!antodo 67
  PetscErrorCode ierr;
1928 jroman 68
  PetscInt       listor, lrstor, ncuv, k1, k2, k3, k4;
476 dsic.upv.es!antodo 69
  EPS_BLZPACK    *blz = (EPS_BLZPACK *)eps->data;
70
  PetscTruth     flg;
71
  KSP            ksp;
72
  PC             pc;
6 dsic.upv.es!jroman 73
 
74
  PetscFunctionBegin;
260 dsic.upv.es!antodo 75
  if (eps->ncv) {
76
    if( eps->ncv < PetscMin(eps->nev+10,eps->nev*2) )
77
      SETERRQ(0,"Warning: BLZpack recommends that ncv be larger than min(nev+10,nev*2)");
78
  }
79
  else eps->ncv = PetscMin(eps->nev+10,eps->nev*2);
1579 slepc 80
  if (eps->mpd) PetscInfo(eps,"Warning: parameter mpd ignored\n");
1928 jroman 81
  if (!eps->max_it) eps->max_it = PetscMax(1000,eps->n);
260 dsic.upv.es!antodo 82
 
6 dsic.upv.es!jroman 83
  if (!eps->ishermitian)
84
    SETERRQ(PETSC_ERR_SUP,"Requested method is only available for Hermitian problems");
1229 slepc 85
  if (blz->slice || eps->isgeneralized) {
420 dsic.upv.es!antodo 86
    ierr = PetscTypeCompare((PetscObject)eps->OP,STSINV,&flg);CHKERRQ(ierr);
87
    if (!flg)
1229 slepc 88
      SETERRQ(PETSC_ERR_SUP,"Shift-and-invert ST is needed for generalized problems or spectrum slicing");
420 dsic.upv.es!antodo 89
    ierr = STGetKSP(eps->OP,&ksp);CHKERRQ(ierr);
90
    ierr = PetscTypeCompare((PetscObject)ksp,KSPPREONLY,&flg);CHKERRQ(ierr);
91
    if (!flg)
1229 slepc 92
      SETERRQ(PETSC_ERR_SUP,"Preonly KSP is needed for generalized problems or spectrum slicing");
420 dsic.upv.es!antodo 93
    ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr);
94
    ierr = PetscTypeCompare((PetscObject)pc,PCCHOLESKY,&flg);CHKERRQ(ierr);
95
    if (!flg)
1229 slepc 96
      SETERRQ(PETSC_ERR_SUP,"Cholesky PC is needed for generalized problems or spectrum slicing");
420 dsic.upv.es!antodo 97
  }
92 dsic.upv.es!antodo 98
  if (eps->which!=EPS_SMALLEST_REAL)
6 dsic.upv.es!jroman 99
    SETERRQ(1,"Wrong value of eps->which");
100
 
1928 jroman 101
  k1 = PetscMin(eps->n,180);
211 dsic.upv.es!antodo 102
  k2 = blz->block_size;
1928 jroman 103
  k4 = PetscMin(eps->ncv,eps->n);
6 dsic.upv.es!jroman 104
  k3 = 484+k1*(13+k1*2+k2+PetscMax(18,k2+2))+k2*k2*3+k4*2;
105
 
106
  listor = 123+k1*12;
1040 slepc 107
  ierr = PetscFree(blz->istor);CHKERRQ(ierr);
1509 slepc 108
  ierr = PetscMalloc((17+listor)*sizeof(PetscBLASInt),&blz->istor);CHKERRQ(ierr);
1649 slepc 109
  blz->istor[14] = PetscBLASIntCast(listor);
6 dsic.upv.es!jroman 110
 
1928 jroman 111
  if (blz->slice) lrstor = eps->nloc*(k2*4+k1*2+k4)+k3;
112
  else lrstor = eps->nloc*(k2*4+k1)+k3;
1040 slepc 113
  ierr = PetscFree(blz->rstor);CHKERRQ(ierr);
6 dsic.upv.es!jroman 114
  ierr = PetscMalloc((4+lrstor)*sizeof(PetscReal),&blz->rstor);CHKERRQ(ierr);
115
  blz->rstor[3] = lrstor;
116
 
117
  ncuv = PetscMax(3,blz->block_size);
1040 slepc 118
  ierr = PetscFree(blz->u);CHKERRQ(ierr);
1928 jroman 119
  ierr = PetscMalloc(ncuv*eps->nloc*sizeof(PetscScalar),&blz->u);CHKERRQ(ierr);
1040 slepc 120
  ierr = PetscFree(blz->v);CHKERRQ(ierr);
1928 jroman 121
  ierr = PetscMalloc(ncuv*eps->nloc*sizeof(PetscScalar),&blz->v);CHKERRQ(ierr);
6 dsic.upv.es!jroman 122
 
1040 slepc 123
  ierr = PetscFree(blz->eig);CHKERRQ(ierr);
6 dsic.upv.es!jroman 124
  ierr = PetscMalloc(2*eps->ncv*sizeof(PetscReal),&blz->eig);CHKERRQ(ierr);
125
 
1560 slepc 126
  if (eps->extraction) {
127
     ierr = PetscInfo(eps,"Warning: extraction type ignored\n");CHKERRQ(ierr);
1426 slepc 128
  }
129
 
1596 slepc 130
  ierr = EPSAllocateSolution(eps);CHKERRQ(ierr);
6 dsic.upv.es!jroman 131
  PetscFunctionReturn(0);
132
}
133
 
134
#undef __FUNCT__  
135
#define __FUNCT__ "EPSSolve_BLZPACK"
476 dsic.upv.es!antodo 136
PetscErrorCode EPSSolve_BLZPACK(EPS eps)
6 dsic.upv.es!jroman 137
{
476 dsic.upv.es!antodo 138
  PetscErrorCode ierr;
1089 slepc 139
  EPS_BLZPACK    *blz = (EPS_BLZPACK *)eps->data;
1928 jroman 140
  PetscInt       nn;
1509 slepc 141
  PetscBLASInt   i, nneig, lflag, nvopu;      
476 dsic.upv.es!antodo 142
  Vec            x, y;                          
143
  PetscScalar    sigma,*pV;                      
144
  Mat            A;                              
145
  KSP            ksp;                            
146
  PC             pc;                            
6 dsic.upv.es!jroman 147
 
148
  PetscFunctionBegin;
149
 
1928 jroman 150
  ierr = VecCreateMPIWithArray(((PetscObject)eps)->comm,eps->nloc,PETSC_DECIDE,PETSC_NULL,&x);CHKERRQ(ierr);
151
  ierr = VecCreateMPIWithArray(((PetscObject)eps)->comm,eps->nloc,PETSC_DECIDE,PETSC_NULL,&y);CHKERRQ(ierr);
6 dsic.upv.es!jroman 152
  ierr = VecGetArray(eps->V[0],&pV);CHKERRQ(ierr);
153
 
1229 slepc 154
  if (eps->isgeneralized && !blz->slice) {
155
    ierr = STGetShift(eps->OP,&sigma);CHKERRQ(ierr); /* shift of origin */
156
    blz->rstor[0]  = sigma;        /* lower limit of eigenvalue interval */
157
    blz->rstor[1]  = sigma;        /* upper limit of eigenvalue interval */
158
  } else {
159
    sigma = 0.0;
160
    blz->rstor[0]  = blz->initial; /* lower limit of eigenvalue interval */
161
    blz->rstor[1]  = blz->final;   /* upper limit of eigenvalue interval */
162
  }
420 dsic.upv.es!antodo 163
  nneig = 0;                     /* no. of eigs less than sigma */
164
 
1928 jroman 165
  blz->istor[0]  = PetscBLASIntCast(eps->nloc); /* number of rows of U, V, X*/
166
  blz->istor[1]  = PetscBLASIntCast(eps->nloc); /* leading dimension of U, V, X */
1649 slepc 167
  blz->istor[2]  = PetscBLASIntCast(eps->nev); /* number of required eigenpairs */
168
  blz->istor[3]  = PetscBLASIntCast(eps->ncv); /* number of working eigenpairs */
6 dsic.upv.es!jroman 169
  blz->istor[4]  = blz->block_size;    /* number of vectors in a block */
422 dsic.upv.es!antodo 170
  blz->istor[5]  = blz->nsteps;  /* maximun number of steps per run */
6 dsic.upv.es!jroman 171
  blz->istor[6]  = 1;            /* number of starting vectors as input */
172
  blz->istor[7]  = 0;            /* number of eigenpairs given as input */
1229 slepc 173
  blz->istor[8]  = (blz->slice || eps->isgeneralized) ? 1 : 0;   /* problem type */
420 dsic.upv.es!antodo 174
  blz->istor[9]  = blz->slice;   /* spectrum slicing */
1229 slepc 175
  blz->istor[10] = eps->isgeneralized ? 1 : 0;   /* solutions refinement (purify) */
420 dsic.upv.es!antodo 176
  blz->istor[11] = 0;            /* level of printing */
6 dsic.upv.es!jroman 177
  blz->istor[12] = 6;            /* file unit for output */
1649 slepc 178
  blz->istor[13] = PetscBLASIntCast(MPI_Comm_c2f(((PetscObject)eps)->comm)); /* communicator */
6 dsic.upv.es!jroman 179
 
180
  blz->rstor[2]  = eps->tol;     /* threshold for convergence */
181
 
182
  lflag = 0;           /* reverse communication interface flag */
183
 
422 dsic.upv.es!antodo 184
  do {
6 dsic.upv.es!jroman 185
 
186
    BLZpack_( blz->istor, blz->rstor, &sigma, &nneig, blz->u, blz->v,
187
              &lflag, &nvopu, blz->eig, pV );
188
 
422 dsic.upv.es!antodo 189
    switch (lflag) {
190
    case 1:
6 dsic.upv.es!jroman 191
      /* compute v = OP u */
192
      for (i=0;i<nvopu;i++) {
1928 jroman 193
        ierr = VecPlaceArray( x, blz->u+i*eps->nloc );CHKERRQ(ierr);
194
        ierr = VecPlaceArray( y, blz->v+i*eps->nloc );CHKERRQ(ierr);
1229 slepc 195
        if (blz->slice || eps->isgeneralized) {
196
          ierr = STAssociatedKSPSolve( eps->OP, x, y );CHKERRQ(ierr);
6 dsic.upv.es!jroman 197
        } else {
198
          ierr = STApply( eps->OP, x, y ); CHKERRQ(ierr);
199
        }
1755 antodo 200
        ierr = IPOrthogonalize(eps->ip,0,PETSC_NULL,eps->nds,PETSC_NULL,eps->DS,y,PETSC_NULL,PETSC_NULL,PETSC_NULL);CHKERRQ(ierr);
850 dsic.upv.es!antodo 201
        ierr = VecResetArray(x);CHKERRQ(ierr);
202
        ierr = VecResetArray(y);CHKERRQ(ierr); 
6 dsic.upv.es!jroman 203
      }
422 dsic.upv.es!antodo 204
      /* monitor */
205
      eps->nconv  = BLZistorr_(blz->istor,"NTEIG",5);
206
      EPSMonitor(eps,eps->its,eps->nconv,
207
        blz->rstor+BLZistorr_(blz->istor,"IRITZ",5),
208
        eps->eigi,
209
        blz->rstor+BLZistorr_(blz->istor,"IRITZ",5)+BLZistorr_(blz->istor,"JT",2),
210
        BLZistorr_(blz->istor,"NRITZ",5));
624 dsic.upv.es!antodo 211
      eps->its = eps->its + 1;
422 dsic.upv.es!antodo 212
      if (eps->its >= eps->max_it || eps->nconv >= eps->nev) lflag = 5;
213
      break;
214
    case 2:  
6 dsic.upv.es!jroman 215
      /* compute v = B u */
216
      for (i=0;i<nvopu;i++) {
1928 jroman 217
        ierr = VecPlaceArray( x, blz->u+i*eps->nloc );CHKERRQ(ierr);
218
        ierr = VecPlaceArray( y, blz->v+i*eps->nloc );CHKERRQ(ierr);
1358 slepc 219
        ierr = IPApplyMatrix(eps->ip, x, y ); CHKERRQ(ierr);
850 dsic.upv.es!antodo 220
        ierr = VecResetArray(x);CHKERRQ(ierr);
221
        ierr = VecResetArray(y);CHKERRQ(ierr); 
6 dsic.upv.es!jroman 222
      }
422 dsic.upv.es!antodo 223
      break;
224
    case 3:  
6 dsic.upv.es!jroman 225
      /* update shift */
1229 slepc 226
      PetscInfo1(eps,"Factorization update (sigma=%g)\n",sigma);
420 dsic.upv.es!antodo 227
      ierr = STSetShift(eps->OP,sigma);CHKERRQ(ierr);
228
      ierr = STGetKSP(eps->OP,&ksp);CHKERRQ(ierr);
229
      ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr);
1649 slepc 230
      ierr = PCFactorGetMatrix(pc,&A);CHKERRQ(ierr);
1089 slepc 231
      ierr = MatGetInertia(A,&nn,PETSC_NULL,PETSC_NULL);CHKERRQ(ierr);
1649 slepc 232
      nneig = PetscBLASIntCast(nn);
422 dsic.upv.es!antodo 233
      break;
234
    case 4:  
6 dsic.upv.es!jroman 235
      /* copy the initial vector */
236
      ierr = VecPlaceArray(x,blz->v);CHKERRQ(ierr);
1229 slepc 237
      ierr = EPSGetStartVector(eps,0,x,PETSC_NULL);CHKERRQ(ierr);
850 dsic.upv.es!antodo 238
      ierr = VecResetArray(x);CHKERRQ(ierr);
422 dsic.upv.es!antodo 239
      break;
6 dsic.upv.es!jroman 240
    }
422 dsic.upv.es!antodo 241
 
242
  } while (lflag > 0);
6 dsic.upv.es!jroman 243
 
244
  ierr = VecRestoreArray( eps->V[0], &pV ); CHKERRQ(ierr);
245
 
246
  eps->nconv  = BLZistorr_(blz->istor,"NTEIG",5);
247
  eps->reason = EPS_CONVERGED_TOL;
248
 
249
  for (i=0;i<eps->nconv;i++) {
250
    eps->eigr[i]=blz->eig[i];
251
  }
252
 
114 dsic.upv.es!antodo 253
  if (lflag!=0) {
254
    char msg[2048] = "";
255
    for (i = 0; i < 33; i++) {
134 dsic.upv.es!antodo 256
      if (blz->istor[15] & (1 << i)) PetscStrcat(msg, blzpack_error[i]);
114 dsic.upv.es!antodo 257
    }
258
    SETERRQ2(PETSC_ERR_LIB,"Error in BLZPACK (code=%d): '%s'",blz->istor[15], msg);
259
  }
6 dsic.upv.es!jroman 260
  ierr = VecDestroy(x);CHKERRQ(ierr);
261
  ierr = VecDestroy(y);CHKERRQ(ierr);
262
 
263
  PetscFunctionReturn(0);
264
}
265
 
266
#undef __FUNCT__  
420 dsic.upv.es!antodo 267
#define __FUNCT__ "EPSBackTransform_BLZPACK"
476 dsic.upv.es!antodo 268
PetscErrorCode EPSBackTransform_BLZPACK(EPS eps)
420 dsic.upv.es!antodo 269
{
476 dsic.upv.es!antodo 270
  PetscErrorCode ierr;
271
  EPS_BLZPACK    *blz = (EPS_BLZPACK *)eps->data;
420 dsic.upv.es!antodo 272
 
273
  PetscFunctionBegin;
1229 slepc 274
  if (!blz->slice && !eps->isgeneralized) {
442 dsic.upv.es!antodo 275
    ierr = EPSBackTransform_Default(eps);CHKERRQ(ierr);
276
  }
420 dsic.upv.es!antodo 277
  PetscFunctionReturn(0);
278
}
279
 
280
#undef __FUNCT__  
6 dsic.upv.es!jroman 281
#define __FUNCT__ "EPSDestroy_BLZPACK"
476 dsic.upv.es!antodo 282
PetscErrorCode EPSDestroy_BLZPACK(EPS eps)
6 dsic.upv.es!jroman 283
{
476 dsic.upv.es!antodo 284
  PetscErrorCode ierr;
285
  EPS_BLZPACK    *blz = (EPS_BLZPACK *)eps->data;
6 dsic.upv.es!jroman 286
 
287
  PetscFunctionBegin;
25 dsic.upv.es!jroman 288
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
1040 slepc 289
  ierr = PetscFree(blz->istor);CHKERRQ(ierr);
290
  ierr = PetscFree(blz->rstor);CHKERRQ(ierr);
291
  ierr = PetscFree(blz->u);CHKERRQ(ierr);
292
  ierr = PetscFree(blz->v);CHKERRQ(ierr);
293
  ierr = PetscFree(blz->eig);CHKERRQ(ierr);
294
  ierr = PetscFree(eps->data);CHKERRQ(ierr);
1596 slepc 295
  ierr = EPSFreeSolution(eps);CHKERRQ(ierr);
1925 jroman 296
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSBlzpackSetBlockSize_C","",PETSC_NULL);CHKERRQ(ierr);
297
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSBlzpackSetInterval_C","",PETSC_NULL);CHKERRQ(ierr);
298
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSBlzpackSetNSteps_C","",PETSC_NULL);CHKERRQ(ierr);
6 dsic.upv.es!jroman 299
  PetscFunctionReturn(0);
300
}
301
 
302
#undef __FUNCT__  
303
#define __FUNCT__ "EPSView_BLZPACK"
476 dsic.upv.es!antodo 304
PetscErrorCode EPSView_BLZPACK(EPS eps,PetscViewer viewer)
6 dsic.upv.es!jroman 305
{
476 dsic.upv.es!antodo 306
  PetscErrorCode ierr;
307
  EPS_BLZPACK    *blz = (EPS_BLZPACK *) eps->data;
308
  PetscTruth     isascii;
6 dsic.upv.es!jroman 309
 
310
  PetscFunctionBegin;
311
  ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_ASCII,&isascii);CHKERRQ(ierr);
312
  if (!isascii) {
313
    SETERRQ1(1,"Viewer type %s not supported for EPSBLZPACK",((PetscObject)viewer)->type_name);
314
  }
315
  ierr = PetscViewerASCIIPrintf(viewer,"block size of the block-Lanczos algorithm: %d\n",blz->block_size);CHKERRQ(ierr);
316
  ierr = PetscViewerASCIIPrintf(viewer,"computational interval: [%f,%f]\n",blz->initial,blz->final);CHKERRQ(ierr);
317
  PetscFunctionReturn(0);
318
}
319
 
320
#undef __FUNCT__  
321
#define __FUNCT__ "EPSSetFromOptions_BLZPACK"
476 dsic.upv.es!antodo 322
PetscErrorCode EPSSetFromOptions_BLZPACK(EPS eps)
6 dsic.upv.es!jroman 323
{
476 dsic.upv.es!antodo 324
  PetscErrorCode ierr;
325
  EPS_BLZPACK    *blz = (EPS_BLZPACK *)eps->data;
1089 slepc 326
  PetscInt       bs,n;
476 dsic.upv.es!antodo 327
  PetscReal      interval[2];
328
  PetscTruth     flg;
329
  KSP            ksp;
330
  PC             pc;
6 dsic.upv.es!jroman 331
 
332
  PetscFunctionBegin;
333
  ierr = PetscOptionsHead("BLZPACK options");CHKERRQ(ierr);
334
 
444 dsic.upv.es!antodo 335
  bs = blz->block_size;
336
  ierr = PetscOptionsInt("-eps_blzpack_block_size","Block size","EPSBlzpackSetBlockSize",bs,&bs,&flg);CHKERRQ(ierr);
337
  if (flg) {ierr = EPSBlzpackSetBlockSize(eps,bs);CHKERRQ(ierr);}
6 dsic.upv.es!jroman 338
 
444 dsic.upv.es!antodo 339
  n = blz->nsteps;
340
  ierr = PetscOptionsInt("-eps_blzpack_nsteps","Number of steps","EPSBlzpackSetNSteps",n,&n,&flg);CHKERRQ(ierr);
341
  if (flg) {ierr = EPSBlzpackSetNSteps(eps,n);CHKERRQ(ierr);}
422 dsic.upv.es!antodo 342
 
444 dsic.upv.es!antodo 343
  interval[0] = blz->initial;
344
  interval[1] = blz->final;
345
  n = 2;
346
  ierr = PetscOptionsRealArray("-eps_blzpack_interval","Computational interval","EPSBlzpackSetInterval",interval,&n,&flg);CHKERRQ(ierr);
347
  if (flg) {
348
    if (n==1) interval[1]=interval[0];
349
    ierr = EPSBlzpackSetInterval(eps,interval[0],interval[1]);CHKERRQ(ierr);
350
  }
6 dsic.upv.es!jroman 351
 
1229 slepc 352
  if (blz->slice || eps->isgeneralized) {
444 dsic.upv.es!antodo 353
    ierr = STSetType(eps->OP,STSINV);CHKERRQ(ierr);
354
    ierr = STGetKSP(eps->OP,&ksp);CHKERRQ(ierr);
355
    ierr = KSPSetType(ksp,KSPPREONLY);CHKERRQ(ierr);
356
    ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr);
357
    ierr = PCSetType(pc,PCCHOLESKY);CHKERRQ(ierr);
358
  }
359
 
6 dsic.upv.es!jroman 360
  ierr = PetscOptionsTail();CHKERRQ(ierr);
361
  PetscFunctionReturn(0);
362
}
363
 
364
EXTERN_C_BEGIN
365
#undef __FUNCT__  
366
#define __FUNCT__ "EPSBlzpackSetBlockSize_BLZPACK"
1509 slepc 367
PetscErrorCode EPSBlzpackSetBlockSize_BLZPACK(EPS eps,PetscInt bs)
6 dsic.upv.es!jroman 368
{
476 dsic.upv.es!antodo 369
  EPS_BLZPACK *blz = (EPS_BLZPACK *) eps->data;;
6 dsic.upv.es!jroman 370
 
371
  PetscFunctionBegin;
211 dsic.upv.es!antodo 372
  if (bs == PETSC_DEFAULT) blz->block_size = 3;
373
  else if (bs <= 0) {
374
    SETERRQ(1, "Incorrect block size");
1649 slepc 375
  } else blz->block_size = PetscBLASIntCast(bs);
6 dsic.upv.es!jroman 376
  PetscFunctionReturn(0);
377
}
378
EXTERN_C_END
379
 
380
#undef __FUNCT__  
381
#define __FUNCT__ "EPSBlzpackSetBlockSize"
382
/*@
383
   EPSBlzpackSetBlockSize - Sets the block size for the BLZPACK package.
384
 
385
   Collective on EPS
386
 
387
   Input Parameters:
388
+  eps - the eigenproblem solver context
389
-  bs - block size
390
 
391
   Options Database Key:
392
.  -eps_blzpack_block_size - Sets the value of the block size
393
 
394
   Level: advanced
395
 
553 dsic.upv.es!jroman 396
.seealso: EPSBlzpackSetInterval()
6 dsic.upv.es!jroman 397
@*/
1509 slepc 398
PetscErrorCode EPSBlzpackSetBlockSize(EPS eps,PetscInt bs)
6 dsic.upv.es!jroman 399
{
1509 slepc 400
  PetscErrorCode ierr, (*f)(EPS,PetscInt);
6 dsic.upv.es!jroman 401
 
402
  PetscFunctionBegin;
25 dsic.upv.es!jroman 403
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
6 dsic.upv.es!jroman 404
  ierr = PetscObjectQueryFunction((PetscObject)eps,"EPSBlzpackSetBlockSize_C",(void (**)())&f);CHKERRQ(ierr);
405
  if (f) {
406
    ierr = (*f)(eps,bs);CHKERRQ(ierr);
407
  }
408
  PetscFunctionReturn(0);
409
}
410
 
411
EXTERN_C_BEGIN
412
#undef __FUNCT__  
413
#define __FUNCT__ "EPSBlzpackSetInterval_BLZPACK"
476 dsic.upv.es!antodo 414
PetscErrorCode EPSBlzpackSetInterval_BLZPACK(EPS eps,PetscReal initial,PetscReal final)
6 dsic.upv.es!jroman 415
{
1229 slepc 416
  PetscErrorCode ierr;
476 dsic.upv.es!antodo 417
  EPS_BLZPACK *blz = (EPS_BLZPACK *) eps->data;;
6 dsic.upv.es!jroman 418
 
419
  PetscFunctionBegin;
420
  blz->initial    = initial;
421
  blz->final      = final;
420 dsic.upv.es!antodo 422
  blz->slice      = 1;
1229 slepc 423
  ierr = STSetShift(eps->OP,initial);CHKERRQ(ierr);
6 dsic.upv.es!jroman 424
  PetscFunctionReturn(0);
425
}
426
EXTERN_C_END
427
 
428
#undef __FUNCT__  
429
#define __FUNCT__ "EPSBlzpackSetInterval"
430
/*@
431
   EPSBlzpackSetInterval - Sets the computational interval for the BLZPACK
432
   package.
433
 
434
   Collective on EPS
435
 
436
   Input Parameters:
437
+  eps     - the eigenproblem solver context
438
.  initial - lower bound of the interval
439
-  final   - upper bound of the interval
440
 
441
   Options Database Key:
442
.  -eps_blzpack_interval - Sets the bounds of the interval (two values
443
   separated by commas)
444
 
445
   Note:
446
   The following possibilities are accepted (see Blzpack user's guide for
447
   details).
448
     initial>final: start seeking for eigenpairs in the upper bound
449
     initial<final: start in the lower bound
450
     initial=final: run around a single value (no interval)
451
 
452
   Level: advanced
453
 
454
.seealso: EPSBlzpackSetBlockSize()
455
@*/
476 dsic.upv.es!antodo 456
PetscErrorCode EPSBlzpackSetInterval(EPS eps,PetscReal initial,PetscReal final)
6 dsic.upv.es!jroman 457
{
476 dsic.upv.es!antodo 458
  PetscErrorCode ierr, (*f)(EPS,PetscReal,PetscReal);
6 dsic.upv.es!jroman 459
 
460
  PetscFunctionBegin;
25 dsic.upv.es!jroman 461
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
6 dsic.upv.es!jroman 462
  ierr = PetscObjectQueryFunction((PetscObject)eps,"EPSBlzpackSetInterval_C",(void (**)())&f);CHKERRQ(ierr);
463
  if (f) {
464
    ierr = (*f)(eps,initial,final);CHKERRQ(ierr);
465
  }
466
  PetscFunctionReturn(0);
467
}
468
 
469
EXTERN_C_BEGIN
470
#undef __FUNCT__  
422 dsic.upv.es!antodo 471
#define __FUNCT__ "EPSBlzpackSetNSteps_BLZPACK"
1509 slepc 472
PetscErrorCode EPSBlzpackSetNSteps_BLZPACK(EPS eps,PetscInt nsteps)
422 dsic.upv.es!antodo 473
{
476 dsic.upv.es!antodo 474
  EPS_BLZPACK *blz = (EPS_BLZPACK *) eps->data;
422 dsic.upv.es!antodo 475
 
476
  PetscFunctionBegin;
1649 slepc 477
  if (nsteps == PETSC_DEFAULT) blz->nsteps = 0;
478
  else { blz->nsteps = PetscBLASIntCast(nsteps); }
422 dsic.upv.es!antodo 479
  PetscFunctionReturn(0);
480
}
481
EXTERN_C_END
482
 
483
#undef __FUNCT__  
484
#define __FUNCT__ "EPSBlzpackSetNSteps"
485
/*@
486
   EPSBlzpackSetNSteps - Sets the maximum number of steps per run for the BLZPACK
487
   package.
488
 
489
   Collective on EPS
490
 
491
   Input Parameters:
492
+  eps     - the eigenproblem solver context
493
-  nsteps  - maximum number of steps
494
 
495
   Options Database Key:
424 dsic.upv.es!antodo 496
.  -eps_blzpack_nsteps - Sets the maximum number of steps per run
422 dsic.upv.es!antodo 497
 
498
   Level: advanced
499
 
500
@*/
1509 slepc 501
PetscErrorCode EPSBlzpackSetNSteps(EPS eps,PetscInt nsteps)
422 dsic.upv.es!antodo 502
{
1509 slepc 503
  PetscErrorCode ierr, (*f)(EPS,PetscInt);
422 dsic.upv.es!antodo 504
 
505
  PetscFunctionBegin;
506
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
507
  ierr = PetscObjectQueryFunction((PetscObject)eps,"EPSBlzpackSetNSteps_C",(void (**)())&f);CHKERRQ(ierr);
508
  if (f) {
509
    ierr = (*f)(eps,nsteps);CHKERRQ(ierr);
510
  }
511
  PetscFunctionReturn(0);
512
}
513
 
514
EXTERN_C_BEGIN
515
#undef __FUNCT__  
6 dsic.upv.es!jroman 516
#define __FUNCT__ "EPSCreate_BLZPACK"
476 dsic.upv.es!antodo 517
PetscErrorCode EPSCreate_BLZPACK(EPS eps)
6 dsic.upv.es!jroman 518
{
476 dsic.upv.es!antodo 519
  PetscErrorCode ierr;
520
  EPS_BLZPACK    *blzpack;
6 dsic.upv.es!jroman 521
 
522
  PetscFunctionBegin;
523
  ierr = PetscNew(EPS_BLZPACK,&blzpack);CHKERRQ(ierr);
524
  PetscLogObjectMemory(eps,sizeof(EPS_BLZPACK));
525
  eps->data                      = (void *) blzpack;
503 dsic.upv.es!antodo 526
  eps->ops->solve                = EPSSolve_BLZPACK;
6 dsic.upv.es!jroman 527
  eps->ops->setup                = EPSSetUp_BLZPACK;
503 dsic.upv.es!antodo 528
  eps->ops->setfromoptions       = EPSSetFromOptions_BLZPACK;
6 dsic.upv.es!jroman 529
  eps->ops->destroy              = EPSDestroy_BLZPACK;
530
  eps->ops->view                 = EPSView_BLZPACK;
420 dsic.upv.es!antodo 531
  eps->ops->backtransform        = EPSBackTransform_BLZPACK;
503 dsic.upv.es!antodo 532
  eps->ops->computevectors       = EPSComputeVectors_Default;
6 dsic.upv.es!jroman 533
 
211 dsic.upv.es!antodo 534
  blzpack->block_size = 3;
6 dsic.upv.es!jroman 535
  blzpack->initial = 0.0;
536
  blzpack->final = 0.0;
420 dsic.upv.es!antodo 537
  blzpack->slice = 0;
422 dsic.upv.es!antodo 538
  blzpack->nsteps = 0;
539
 
540
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSBlzpackSetBlockSize_C","EPSBlzpackSetBlockSize_BLZPACK",EPSBlzpackSetBlockSize_BLZPACK);CHKERRQ(ierr);
6 dsic.upv.es!jroman 541
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSBlzpackSetInterval_C","EPSBlzpackSetInterval_BLZPACK",EPSBlzpackSetInterval_BLZPACK);CHKERRQ(ierr);
422 dsic.upv.es!antodo 542
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSBlzpackSetNSteps_C","EPSBlzpackSetNSteps_BLZPACK",EPSBlzpackSetNSteps_BLZPACK);CHKERRQ(ierr);
6 dsic.upv.es!jroman 543
 
104 dsic.upv.es!antodo 544
  eps->which = EPS_SMALLEST_REAL;
545
 
6 dsic.upv.es!jroman 546
  PetscFunctionReturn(0);
547
}
548
EXTERN_C_END