LCOV - code coverage report
Current view: top level - eps/impls/external/blzpack - blzpack.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 227 246 92.3 %
Date: 2019-10-20 05:41:02 Functions: 15 16 93.8 %

          Line data    Source code
       1             : /*
       2             :    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       3             :    SLEPc - Scalable Library for Eigenvalue Problem Computations
       4             :    Copyright (c) 2002-2019, Universitat Politecnica de Valencia, Spain
       5             : 
       6             :    This file is part of SLEPc.
       7             :    SLEPc is distributed under a 2-clause BSD license (see LICENSE).
       8             :    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       9             : */
      10             : /*
      11             :    This file implements a wrapper to the BLZPACK package
      12             : */
      13             : 
      14             : #include <slepc/private/epsimpl.h>    /*I "slepceps.h" I*/
      15             : #include "blzpack.h"
      16             : 
      17             : const char* blzpack_error[33] = {
      18             :   "",
      19             :   "illegal data, LFLAG ",
      20             :   "illegal data, dimension of (U), (V), (X) ",
      21             :   "illegal data, leading dimension of (U), (V), (X) ",
      22             :   "illegal data, leading dimension of (EIG) ",
      23             :   "illegal data, number of required eigenpairs ",
      24             :   "illegal data, Lanczos algorithm block size ",
      25             :   "illegal data, maximum number of steps ",
      26             :   "illegal data, number of starting vectors ",
      27             :   "illegal data, number of eigenpairs provided ",
      28             :   "illegal data, problem type flag ",
      29             :   "illegal data, spectrum slicing flag ",
      30             :   "illegal data, eigenvectors purification flag ",
      31             :   "illegal data, level of output ",
      32             :   "illegal data, output file unit ",
      33             :   "illegal data, LCOMM (MPI or PVM) ",
      34             :   "illegal data, dimension of ISTOR ",
      35             :   "illegal data, convergence threshold ",
      36             :   "illegal data, dimension of RSTOR ",
      37             :   "illegal data on at least one PE ",
      38             :   "ISTOR(3:14) must be equal on all PEs ",
      39             :   "RSTOR(1:3) must be equal on all PEs ",
      40             :   "not enough space in ISTOR to start eigensolution ",
      41             :   "not enough space in RSTOR to start eigensolution ",
      42             :   "illegal data, number of negative eigenvalues ",
      43             :   "illegal data, entries of V ",
      44             :   "illegal data, entries of X ",
      45             :   "failure in computational subinterval ",
      46             :   "file I/O error, blzpack.__.BQ ",
      47             :   "file I/O error, blzpack.__.BX ",
      48             :   "file I/O error, blzpack.__.Q ",
      49             :   "file I/O error, blzpack.__.X ",
      50             :   "parallel interface error "
      51             : };
      52             : 
      53           6 : PetscErrorCode EPSSetUp_BLZPACK(EPS eps)
      54             : {
      55             :   PetscErrorCode ierr;
      56             :   PetscInt       listor,lrstor,ncuv,k1,k2,k3,k4;
      57           6 :   EPS_BLZPACK    *blz = (EPS_BLZPACK*)eps->data;
      58             :   PetscBool      issinv,istrivial,flg;
      59             : 
      60           6 :   PetscFunctionBegin;
      61           6 :   if (eps->ncv) {
      62           1 :     if (eps->ncv < PetscMin(eps->nev+10,eps->nev*2)) SETERRQ(PetscObjectComm((PetscObject)eps),0,"Warning: BLZpack recommends that ncv be larger than min(nev+10,nev*2)");
      63           5 :   } else eps->ncv = PetscMin(eps->nev+10,eps->nev*2);
      64           6 :   if (eps->mpd) { ierr = PetscInfo(eps,"Warning: parameter mpd ignored\n");CHKERRQ(ierr); }
      65           6 :   if (!eps->max_it) eps->max_it = PetscMax(1000,eps->n);
      66             : 
      67           6 :   if (!blz->block_size) blz->block_size = 3;
      68           6 :   if (!eps->ishermitian) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Requested method is only available for Hermitian problems");
      69           6 :   if (eps->which==EPS_ALL) {
      70           1 :     if (eps->inta==0.0 && eps->intb==0.0) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Must define a computational interval when using EPS_ALL");
      71           1 :     blz->slice = 1;
      72             :   }
      73           6 :   ierr = PetscObjectTypeCompare((PetscObject)eps->st,STSINVERT,&issinv);CHKERRQ(ierr);
      74           6 :   if (blz->slice || eps->isgeneralized) {
      75           1 :     if (!issinv) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Shift-and-invert ST is needed for generalized problems or spectrum slicing");
      76             :   }
      77           6 :   if (blz->slice) {
      78           1 :     if (eps->intb >= PETSC_MAX_REAL) { /* right-open interval */
      79           0 :       if (eps->inta <= PETSC_MIN_REAL) SETERRQ(PetscObjectComm((PetscObject)eps),1,"The defined computational interval should have at least one of their sides bounded");
      80           0 :       ierr = STSetDefaultShift(eps->st,eps->inta);CHKERRQ(ierr);
      81             :     } else {
      82           1 :       ierr = STSetDefaultShift(eps->st,eps->intb);CHKERRQ(ierr);
      83             :     }
      84             :   }
      85           6 :   if (!eps->which) {
      86           1 :     if (issinv) eps->which = EPS_TARGET_REAL;
      87           1 :     else eps->which = EPS_SMALLEST_REAL;
      88             :   }
      89           6 :   if ((issinv && eps->which!=EPS_TARGET_REAL && eps->which!=EPS_TARGET_MAGNITUDE && eps->which!=EPS_ALL) || (!issinv && eps->which!=EPS_SMALLEST_REAL)) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which");
      90           6 :   if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver");
      91             : 
      92           6 :   k1 = PetscMin(eps->n,180);
      93           6 :   k2 = blz->block_size;
      94           6 :   k4 = PetscMin(eps->ncv,eps->n);
      95           6 :   k3 = 484+k1*(13+k1*2+k2+PetscMax(18,k2+2))+k2*k2*3+k4*2;
      96             : 
      97           6 :   listor = 123+k1*12;
      98           6 :   ierr = PetscFree(blz->istor);CHKERRQ(ierr);
      99           6 :   ierr = PetscMalloc1((17+listor),&blz->istor);CHKERRQ(ierr);
     100           6 :   ierr = PetscLogObjectMemory((PetscObject)eps,(17+listor)*sizeof(PetscBLASInt));CHKERRQ(ierr);
     101           6 :   ierr = PetscBLASIntCast(listor,&blz->istor[14]);CHKERRQ(ierr);
     102             : 
     103           6 :   if (blz->slice) lrstor = eps->nloc*(k2*4+k1*2+k4)+k3;
     104           5 :   else lrstor = eps->nloc*(k2*4+k1)+k3;
     105           6 : lrstor*=10;
     106           6 :   ierr = PetscFree(blz->rstor);CHKERRQ(ierr);
     107           6 :   ierr = PetscMalloc1((4+lrstor),&blz->rstor);CHKERRQ(ierr);
     108           6 :   ierr = PetscLogObjectMemory((PetscObject)eps,(4+lrstor)*sizeof(PetscReal));CHKERRQ(ierr);
     109           6 :   blz->rstor[3] = lrstor;
     110             : 
     111           6 :   ncuv = PetscMax(3,blz->block_size);
     112           6 :   ierr = PetscFree(blz->u);CHKERRQ(ierr);
     113           6 :   ierr = PetscMalloc1(ncuv*eps->nloc,&blz->u);CHKERRQ(ierr);
     114           6 :   ierr = PetscLogObjectMemory((PetscObject)eps,ncuv*eps->nloc*sizeof(PetscScalar));CHKERRQ(ierr);
     115           6 :   ierr = PetscFree(blz->v);CHKERRQ(ierr);
     116           6 :   ierr = PetscMalloc1(ncuv*eps->nloc,&blz->v);CHKERRQ(ierr);
     117           6 :   ierr = PetscLogObjectMemory((PetscObject)eps,ncuv*eps->nloc*sizeof(PetscScalar));CHKERRQ(ierr);
     118             : 
     119           6 :   ierr = PetscFree(blz->eig);CHKERRQ(ierr);
     120           6 :   ierr = PetscMalloc1(2*eps->ncv,&blz->eig);CHKERRQ(ierr);
     121           6 :   ierr = PetscLogObjectMemory((PetscObject)eps,2*eps->ncv*sizeof(PetscReal));CHKERRQ(ierr);
     122             : 
     123           6 :   if (eps->extraction) { ierr = PetscInfo(eps,"Warning: extraction type ignored\n");CHKERRQ(ierr); }
     124             : 
     125           6 :   ierr = EPSAllocateSolution(eps,0);CHKERRQ(ierr);
     126           6 :   ierr = EPS_SetInnerProduct(eps);CHKERRQ(ierr);
     127           6 :   ierr = PetscObjectTypeCompare((PetscObject)eps->V,BVVECS,&flg);CHKERRQ(ierr);
     128           6 :   if (flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver requires a BV with contiguous storage");
     129           6 :   ierr = RGIsTrivial(eps->rg,&istrivial);CHKERRQ(ierr);
     130           6 :   if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver does not support region filtering");
     131           6 :   if (eps->stopping!=EPSStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"External packages do not support user-defined stopping test");
     132           6 :   PetscFunctionReturn(0);
     133             : }
     134             : 
     135           6 : PetscErrorCode EPSSolve_BLZPACK(EPS eps)
     136             : {
     137             :   PetscErrorCode ierr;
     138           6 :   EPS_BLZPACK    *blz = (EPS_BLZPACK*)eps->data;
     139             :   PetscInt       nn;
     140             :   PetscBLASInt   i,nneig,lflag,nvopu;
     141             :   Vec            x,y;
     142             :   PetscScalar    sigma,*pV;
     143             :   Mat            A,M;
     144             :   KSP            ksp;
     145             :   PC             pc;
     146             : 
     147           6 :   PetscFunctionBegin;
     148           6 :   ierr = STGetMatrix(eps->st,0,&A);CHKERRQ(ierr);
     149           6 :   ierr = MatCreateVecsEmpty(A,&x,&y);CHKERRQ(ierr);
     150           6 :   ierr = EPSGetStartVector(eps,0,NULL);CHKERRQ(ierr);
     151           6 :   ierr = BVSetActiveColumns(eps->V,0,0);CHKERRQ(ierr);  /* just for deflation space */
     152           6 :   ierr = BVGetArray(eps->V,&pV);CHKERRQ(ierr);
     153             : 
     154           6 :   if (eps->isgeneralized && !blz->slice) {
     155           0 :     ierr = STGetShift(eps->st,&sigma);CHKERRQ(ierr); /* shift of origin */
     156           0 :     blz->rstor[0]  = sigma;        /* lower limit of eigenvalue interval */
     157           0 :     blz->rstor[1]  = sigma;        /* upper limit of eigenvalue interval */
     158             :   } else {
     159           6 :     sigma = 0.0;
     160           6 :     blz->rstor[0]  = eps->inta;    /* lower limit of eigenvalue interval */
     161           6 :     blz->rstor[1]  = eps->intb;    /* upper limit of eigenvalue interval */
     162             :   }
     163           6 :   nneig = 0;                       /* no. of eigs less than sigma */
     164             : 
     165           6 :   ierr = PetscBLASIntCast(eps->nloc,&blz->istor[0]);CHKERRQ(ierr); /* no. of rows of U, V, X */
     166           6 :   ierr = PetscBLASIntCast(eps->nloc,&blz->istor[1]);CHKERRQ(ierr); /* leading dim of U, V, X */
     167           6 :   ierr = PetscBLASIntCast(eps->nev,&blz->istor[2]);CHKERRQ(ierr);  /* required eigenpairs */
     168           6 :   ierr = PetscBLASIntCast(eps->ncv,&blz->istor[3]);CHKERRQ(ierr);  /* working eigenpairs */
     169           6 :   blz->istor[4]  = blz->block_size;    /* number of vectors in a block */
     170           6 :   blz->istor[5]  = blz->nsteps;        /* maximun number of steps per run */
     171           6 :   blz->istor[6]  = 1;                  /* number of starting vectors as input */
     172           6 :   blz->istor[7]  = 0;                  /* number of eigenpairs given as input */
     173           6 :   blz->istor[8]  = (blz->slice || eps->isgeneralized) ? 1 : 0;   /* problem type */
     174           6 :   blz->istor[9]  = blz->slice;         /* spectrum slicing */
     175           6 :   blz->istor[10] = eps->isgeneralized ? 1 : 0;   /* solutions refinement (purify) */
     176           6 :   blz->istor[11] = 0;                  /* level of printing */
     177           6 :   blz->istor[12] = 6;                  /* file unit for output */
     178           6 :   ierr = PetscBLASIntCast(MPI_Comm_c2f(PetscObjectComm((PetscObject)eps)),&blz->istor[13]);CHKERRQ(ierr);
     179             : 
     180           6 :   blz->rstor[2]  = eps->tol;           /* threshold for convergence */
     181             : 
     182           6 :   lflag = 0;           /* reverse communication interface flag */
     183             : 
     184             :   do {
     185         256 :     BLZpack_(blz->istor,blz->rstor,&sigma,&nneig,blz->u,blz->v,&lflag,&nvopu,blz->eig,pV);
     186             : 
     187         256 :     switch (lflag) {
     188             :     case 1:
     189             :       /* compute v = OP u */
     190         515 :       for (i=0;i<nvopu;i++) {
     191         515 :         ierr = VecPlaceArray(x,blz->u+i*eps->nloc);CHKERRQ(ierr);
     192         515 :         ierr = VecPlaceArray(y,blz->v+i*eps->nloc);CHKERRQ(ierr);
     193         515 :         if (blz->slice || eps->isgeneralized) {
     194         320 :           ierr = STMatSolve(eps->st,x,y);CHKERRQ(ierr);
     195             :         } else {
     196         195 :           ierr = STApply(eps->st,x,y);CHKERRQ(ierr);
     197             :         }
     198         515 :         ierr = BVOrthogonalizeVec(eps->V,y,NULL,NULL,NULL);CHKERRQ(ierr);
     199         515 :         ierr = VecResetArray(x);CHKERRQ(ierr);
     200         515 :         ierr = VecResetArray(y);CHKERRQ(ierr);
     201             :       }
     202             :       /* monitor */
     203         145 :       eps->nconv  = BLZistorr_(blz->istor,"NTEIG",5);
     204         145 :       ierr = EPSMonitor(eps,eps->its,eps->nconv,blz->rstor+BLZistorr_(blz->istor,"IRITZ",5),eps->eigi,blz->rstor+BLZistorr_(blz->istor,"IRITZ",5)+BLZistorr_(blz->istor,"JT",2),BLZistorr_(blz->istor,"NRITZ",5));CHKERRQ(ierr);
     205         145 :       eps->its = eps->its + 1;
     206         145 :       if (eps->its >= eps->max_it || eps->nconv >= eps->nev) lflag = 5;
     207             :       break;
     208             :     case 2:
     209             :       /* compute v = B u */
     210         364 :       for (i=0;i<nvopu;i++) {
     211         364 :         ierr = VecPlaceArray(x,blz->u+i*eps->nloc);CHKERRQ(ierr);
     212         364 :         ierr = VecPlaceArray(y,blz->v+i*eps->nloc);CHKERRQ(ierr);
     213         364 :         ierr = BVApplyMatrix(eps->V,x,y);CHKERRQ(ierr);
     214         364 :         ierr = VecResetArray(x);CHKERRQ(ierr);
     215         364 :         ierr = VecResetArray(y);CHKERRQ(ierr);
     216             :       }
     217             :       break;
     218             :     case 3:
     219             :       /* update shift */
     220           4 :       ierr = PetscInfo1(eps,"Factorization update (sigma=%g)\n",(double)sigma);CHKERRQ(ierr);
     221           4 :       ierr = STSetShift(eps->st,sigma);CHKERRQ(ierr);
     222           4 :       ierr = STGetKSP(eps->st,&ksp);CHKERRQ(ierr);
     223           4 :       ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr);
     224           4 :       ierr = PCFactorGetMatrix(pc,&M);CHKERRQ(ierr);
     225           4 :       ierr = MatGetInertia(M,&nn,NULL,NULL);CHKERRQ(ierr);
     226           4 :       ierr = PetscBLASIntCast(nn,&nneig);CHKERRQ(ierr);
     227             :       break;
     228             :     case 4:
     229             :       /* copy the initial vector */
     230           9 :       ierr = VecPlaceArray(x,blz->v);CHKERRQ(ierr);
     231           9 :       ierr = BVCopyVec(eps->V,0,x);CHKERRQ(ierr);
     232           9 :       ierr = VecResetArray(x);CHKERRQ(ierr);
     233             :       break;
     234             :     }
     235             : 
     236         256 :   } while (lflag > 0);
     237             : 
     238           6 :   ierr = BVRestoreArray(eps->V,&pV);CHKERRQ(ierr);
     239             : 
     240           6 :   eps->nconv  = BLZistorr_(blz->istor,"NTEIG",5);
     241           6 :   eps->reason = EPS_CONVERGED_TOL;
     242           6 :   if (blz->slice) eps->nev = eps->nconv;
     243          68 :   for (i=0;i<eps->nconv;i++) eps->eigr[i]=blz->eig[i];
     244             : 
     245           6 :   if (lflag!=0) {
     246           0 :     char msg[2048] = "";
     247           0 :     for (i = 0; i < 33; i++) {
     248           0 :       if (blz->istor[15] & (1 << i)) { ierr = PetscStrcat(msg,blzpack_error[i]);CHKERRQ(ierr); }
     249             :     }
     250           0 :     SETERRQ2(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"Error in BLZPACK (code=%d): '%s'",blz->istor[15],msg);
     251             :   }
     252           6 :   ierr = VecDestroy(&x);CHKERRQ(ierr);
     253           6 :   ierr = VecDestroy(&y);CHKERRQ(ierr);
     254           6 :   PetscFunctionReturn(0);
     255             : }
     256             : 
     257           6 : PetscErrorCode EPSBackTransform_BLZPACK(EPS eps)
     258             : {
     259             :   PetscErrorCode ierr;
     260           6 :   EPS_BLZPACK    *blz = (EPS_BLZPACK*)eps->data;
     261             : 
     262           6 :   PetscFunctionBegin;
     263           6 :   if (!blz->slice && !eps->isgeneralized) {
     264           5 :     ierr = EPSBackTransform_Default(eps);CHKERRQ(ierr);
     265             :   }
     266           6 :   PetscFunctionReturn(0);
     267             : }
     268             : 
     269           5 : PetscErrorCode EPSReset_BLZPACK(EPS eps)
     270             : {
     271             :   PetscErrorCode ierr;
     272           5 :   EPS_BLZPACK    *blz = (EPS_BLZPACK*)eps->data;
     273             : 
     274           5 :   PetscFunctionBegin;
     275           5 :   ierr = PetscFree(blz->istor);CHKERRQ(ierr);
     276           5 :   ierr = PetscFree(blz->rstor);CHKERRQ(ierr);
     277           5 :   ierr = PetscFree(blz->u);CHKERRQ(ierr);
     278           5 :   ierr = PetscFree(blz->v);CHKERRQ(ierr);
     279           5 :   ierr = PetscFree(blz->eig);CHKERRQ(ierr);
     280           5 :   PetscFunctionReturn(0);
     281             : }
     282             : 
     283           5 : PetscErrorCode EPSDestroy_BLZPACK(EPS eps)
     284             : {
     285             :   PetscErrorCode ierr;
     286             : 
     287           5 :   PetscFunctionBegin;
     288           5 :   ierr = PetscFree(eps->data);CHKERRQ(ierr);
     289           5 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSBlzpackSetBlockSize_C",NULL);CHKERRQ(ierr);
     290           5 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSBlzpackGetBlockSize_C",NULL);CHKERRQ(ierr);
     291           5 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSBlzpackSetNSteps_C",NULL);CHKERRQ(ierr);
     292           5 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSBlzpackGetNSteps_C",NULL);CHKERRQ(ierr);
     293           5 :   PetscFunctionReturn(0);
     294             : }
     295             : 
     296           0 : PetscErrorCode EPSView_BLZPACK(EPS eps,PetscViewer viewer)
     297             : {
     298             :   PetscErrorCode ierr;
     299           0 :   EPS_BLZPACK    *blz = (EPS_BLZPACK*)eps->data;
     300             :   PetscBool      isascii;
     301             : 
     302           0 :   PetscFunctionBegin;
     303           0 :   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr);
     304           0 :   if (isascii) {
     305           0 :     ierr = PetscViewerASCIIPrintf(viewer,"  block size=%d\n",blz->block_size);CHKERRQ(ierr);
     306           0 :     ierr = PetscViewerASCIIPrintf(viewer,"  maximum number of steps per run=%d\n",blz->nsteps);CHKERRQ(ierr);
     307           0 :     if (blz->slice) {
     308           0 :       ierr = PetscViewerASCIIPrintf(viewer,"  computational interval [%f,%f]\n",eps->inta,eps->intb);CHKERRQ(ierr);
     309             :     }
     310             :   }
     311           0 :   PetscFunctionReturn(0);
     312             : }
     313             : 
     314           4 : PetscErrorCode EPSSetFromOptions_BLZPACK(PetscOptionItems *PetscOptionsObject,EPS eps)
     315             : {
     316             :   PetscErrorCode ierr;
     317           4 :   EPS_BLZPACK    *blz = (EPS_BLZPACK*)eps->data;
     318             :   PetscInt       bs,n;
     319             :   PetscBool      flg;
     320             : 
     321           4 :   PetscFunctionBegin;
     322           4 :   ierr = PetscOptionsHead(PetscOptionsObject,"EPS BLZPACK Options");CHKERRQ(ierr);
     323             : 
     324           4 :     bs = blz->block_size;
     325           4 :     ierr = PetscOptionsInt("-eps_blzpack_blocksize","Block size","EPSBlzpackSetBlockSize",bs,&bs,&flg);CHKERRQ(ierr);
     326           4 :     if (flg) { ierr = EPSBlzpackSetBlockSize(eps,bs);CHKERRQ(ierr); }
     327             : 
     328           4 :     n = blz->nsteps;
     329           4 :     ierr = PetscOptionsInt("-eps_blzpack_nsteps","Number of steps","EPSBlzpackSetNSteps",n,&n,&flg);CHKERRQ(ierr);
     330           4 :     if (flg) { ierr = EPSBlzpackSetNSteps(eps,n);CHKERRQ(ierr); }
     331             : 
     332           4 :   ierr = PetscOptionsTail();CHKERRQ(ierr);
     333           4 :   PetscFunctionReturn(0);
     334             : }
     335             : 
     336           1 : static PetscErrorCode EPSBlzpackSetBlockSize_BLZPACK(EPS eps,PetscInt bs)
     337             : {
     338             :   PetscErrorCode ierr;
     339           1 :   EPS_BLZPACK    *blz = (EPS_BLZPACK*)eps->data;
     340             : 
     341           1 :   PetscFunctionBegin;
     342           1 :   if (bs == PETSC_DEFAULT) blz->block_size = 3;
     343           1 :   else if (bs <= 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Block size must be positive");
     344             :   else {
     345           1 :     ierr = PetscBLASIntCast(bs,&blz->block_size);CHKERRQ(ierr);
     346             :   }
     347           1 :   PetscFunctionReturn(0);
     348             : }
     349             : 
     350             : /*@
     351             :    EPSBlzpackSetBlockSize - Sets the block size for the BLZPACK package.
     352             : 
     353             :    Collective on eps
     354             : 
     355             :    Input Parameters:
     356             : +  eps - the eigenproblem solver context
     357             : -  bs - block size
     358             : 
     359             :    Options Database Key:
     360             : .  -eps_blzpack_blocksize - Sets the value of the block size
     361             : 
     362             :    Level: advanced
     363             : @*/
     364           1 : PetscErrorCode EPSBlzpackSetBlockSize(EPS eps,PetscInt bs)
     365             : {
     366             :   PetscErrorCode ierr;
     367             : 
     368           1 :   PetscFunctionBegin;
     369           1 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     370           2 :   PetscValidLogicalCollectiveInt(eps,bs,2);
     371           1 :   ierr = PetscTryMethod(eps,"EPSBlzpackSetBlockSize_C",(EPS,PetscInt),(eps,bs));CHKERRQ(ierr);
     372           2 :   PetscFunctionReturn(0);
     373             : }
     374             : 
     375           1 : static PetscErrorCode EPSBlzpackGetBlockSize_BLZPACK(EPS eps,PetscInt *bs)
     376             : {
     377           1 :   EPS_BLZPACK *blz = (EPS_BLZPACK*)eps->data;
     378             : 
     379           1 :   PetscFunctionBegin;
     380           1 :   *bs = blz->block_size;
     381           1 :   PetscFunctionReturn(0);
     382             : }
     383             : 
     384             : /*@
     385             :    EPSBlzpackGetBlockSize - Gets the block size used in the BLZPACK solver.
     386             : 
     387             :    Not Collective
     388             : 
     389             :    Input Parameter:
     390             : .  eps - the eigenproblem solver context
     391             : 
     392             :    Output Parameter:
     393             : .  bs - the block size
     394             : 
     395             :    Level: advanced
     396             : 
     397             : .seealso: EPSBlzpackSetBlockSize()
     398             : @*/
     399           1 : PetscErrorCode EPSBlzpackGetBlockSize(EPS eps,PetscInt *bs)
     400             : {
     401             :   PetscErrorCode ierr;
     402             : 
     403           1 :   PetscFunctionBegin;
     404           1 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     405           1 :   PetscValidIntPointer(bs,2);
     406           1 :   ierr = PetscUseMethod(eps,"EPSBlzpackGetBlockSize_C",(EPS,PetscInt*),(eps,bs));CHKERRQ(ierr);
     407           2 :   PetscFunctionReturn(0);
     408             : }
     409             : 
     410           1 : static PetscErrorCode EPSBlzpackSetNSteps_BLZPACK(EPS eps,PetscInt nsteps)
     411             : {
     412             :   PetscErrorCode ierr;
     413           1 :   EPS_BLZPACK    *blz = (EPS_BLZPACK*)eps->data;
     414             : 
     415           1 :   PetscFunctionBegin;
     416           1 :   if (nsteps == PETSC_DEFAULT) blz->nsteps = 0;
     417             :   else {
     418           1 :     ierr = PetscBLASIntCast(nsteps,&blz->nsteps);CHKERRQ(ierr);
     419             :   }
     420           1 :   PetscFunctionReturn(0);
     421             : }
     422             : 
     423             : /*@
     424             :    EPSBlzpackSetNSteps - Sets the maximum number of steps per run for the BLZPACK
     425             :    package.
     426             : 
     427             :    Collective on eps
     428             : 
     429             :    Input Parameters:
     430             : +  eps     - the eigenproblem solver context
     431             : -  nsteps  - maximum number of steps
     432             : 
     433             :    Options Database Key:
     434             : .  -eps_blzpack_nsteps - Sets the maximum number of steps per run
     435             : 
     436             :    Level: advanced
     437             : 
     438             : @*/
     439           1 : PetscErrorCode EPSBlzpackSetNSteps(EPS eps,PetscInt nsteps)
     440             : {
     441             :   PetscErrorCode ierr;
     442             : 
     443           1 :   PetscFunctionBegin;
     444           1 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     445           2 :   PetscValidLogicalCollectiveInt(eps,nsteps,2);
     446           1 :   ierr = PetscTryMethod(eps,"EPSBlzpackSetNSteps_C",(EPS,PetscInt),(eps,nsteps));CHKERRQ(ierr);
     447           2 :   PetscFunctionReturn(0);
     448             : }
     449             : 
     450           1 : static PetscErrorCode EPSBlzpackGetNSteps_BLZPACK(EPS eps,PetscInt *nsteps)
     451             : {
     452           1 :   EPS_BLZPACK *blz = (EPS_BLZPACK*)eps->data;
     453             : 
     454           1 :   PetscFunctionBegin;
     455           1 :   *nsteps = blz->nsteps;
     456           1 :   PetscFunctionReturn(0);
     457             : }
     458             : 
     459             : /*@
     460             :    EPSBlzpackGetNSteps - Gets the maximum number of steps per run in the BLZPACK solver.
     461             : 
     462             :    Not Collective
     463             : 
     464             :    Input Parameter:
     465             : .  eps - the eigenproblem solver context
     466             : 
     467             :    Output Parameter:
     468             : .  nsteps - the maximum number of steps
     469             : 
     470             :    Level: advanced
     471             : 
     472             : .seealso: EPSBlzpackSetNSteps()
     473             : @*/
     474           1 : PetscErrorCode EPSBlzpackGetNSteps(EPS eps,PetscInt *nsteps)
     475             : {
     476             :   PetscErrorCode ierr;
     477             : 
     478           1 :   PetscFunctionBegin;
     479           1 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     480           1 :   PetscValidIntPointer(nsteps,2);
     481           1 :   ierr = PetscUseMethod(eps,"EPSBlzpackGetNSteps_C",(EPS,PetscInt*),(eps,nsteps));CHKERRQ(ierr);
     482           2 :   PetscFunctionReturn(0);
     483             : }
     484             : 
     485           5 : SLEPC_EXTERN PetscErrorCode EPSCreate_BLZPACK(EPS eps)
     486             : {
     487             :   PetscErrorCode ierr;
     488             :   EPS_BLZPACK    *blzpack;
     489             : 
     490           5 :   PetscFunctionBegin;
     491           5 :   ierr = PetscNewLog(eps,&blzpack);CHKERRQ(ierr);
     492           5 :   eps->data = (void*)blzpack;
     493             : 
     494           5 :   eps->ops->solve          = EPSSolve_BLZPACK;
     495           5 :   eps->ops->setup          = EPSSetUp_BLZPACK;
     496           5 :   eps->ops->setfromoptions = EPSSetFromOptions_BLZPACK;
     497           5 :   eps->ops->destroy        = EPSDestroy_BLZPACK;
     498           5 :   eps->ops->reset          = EPSReset_BLZPACK;
     499           5 :   eps->ops->view           = EPSView_BLZPACK;
     500           5 :   eps->ops->backtransform  = EPSBackTransform_BLZPACK;
     501             : 
     502           5 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSBlzpackSetBlockSize_C",EPSBlzpackSetBlockSize_BLZPACK);CHKERRQ(ierr);
     503           5 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSBlzpackGetBlockSize_C",EPSBlzpackGetBlockSize_BLZPACK);CHKERRQ(ierr);
     504           5 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSBlzpackSetNSteps_C",EPSBlzpackSetNSteps_BLZPACK);CHKERRQ(ierr);
     505           5 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSBlzpackGetNSteps_C",EPSBlzpackGetNSteps_BLZPACK);CHKERRQ(ierr);
     506           5 :   PetscFunctionReturn(0);
     507             : }
     508             : 

Generated by: LCOV version 1.13