LCOV - code coverage report
Current view: top level - eps/impls/external/blzpack - blzpack.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 223 242 92.1 %
Date: 2020-05-28 03:14:05 Functions: 15 16 93.8 %

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

Generated by: LCOV version 1.13