| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| 3 | SLEPc - Scalable Library for Eigenvalue Problem Computations | ||
| 4 | Copyright (c) 2002-, 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 | static char help[] = "Test interface to external package ChASE.\n\n" | ||
| 12 | "This is based on ex3.c. The command line options are:\n" | ||
| 13 | " -n <n>, where <n> = number of grid subdivisions in x dimension.\n" | ||
| 14 | " -m <m>, where <m> = number of grid subdivisions in y dimension.\n\n"; | ||
| 15 | |||
| 16 | #include <slepceps.h> | ||
| 17 | |||
| 18 | 6 | int main(int argc,char **argv) | |
| 19 | { | ||
| 20 | 6 | Mat A; /* matrix */ | |
| 21 | 6 | EPS eps; /* eigenproblem solver context */ | |
| 22 | 6 | PetscInt N,n=35,m,Istart,Iend,II,i,j,deg; | |
| 23 | 6 | PetscBool opt,flag; | |
| 24 | |||
| 25 | 6 | PetscFunctionBeginUser; | |
| 26 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(SlepcInitialize(&argc,&argv,NULL,help)); |
| 27 | |||
| 28 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL)); |
| 29 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag)); |
| 30 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
6 | if (!flag) m=n; |
| 31 | 6 | N = n*m; | |
| 32 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(PetscPrintf(PETSC_COMM_WORLD,"\nStandard eigenproblem with ChASE, N=%" PetscInt_FMT " (%" PetscInt_FMT "x%" PetscInt_FMT " grid)\n\n",N,n,m)); |
| 33 | |||
| 34 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| 35 | Compute the matrix that defines the eigensystem, Ax=kx | ||
| 36 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ | ||
| 37 | |||
| 38 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(MatCreate(PETSC_COMM_WORLD,&A)); |
| 39 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N)); |
| 40 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(MatSetFromOptions(A)); |
| 41 | |||
| 42 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(MatGetOwnershipRange(A,&Istart,&Iend)); |
| 43 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
|
4906 | for (II=Istart;II<Iend;II++) { |
| 44 | 4900 | i = II/n; j = II-i*n; | |
| 45 |
3/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
4900 | if (i>0) PetscCall(MatSetValue(A,II,II-n,-1.0,INSERT_VALUES)); |
| 46 |
3/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
4900 | if (i<m-1) PetscCall(MatSetValue(A,II,II+n,-1.0,INSERT_VALUES)); |
| 47 |
3/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
4900 | if (j>0) PetscCall(MatSetValue(A,II,II-1,-1.0,INSERT_VALUES)); |
| 48 |
3/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
4900 | if (j<n-1) PetscCall(MatSetValue(A,II,II+1,-1.0,INSERT_VALUES)); |
| 49 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
4900 | PetscCall(MatSetValue(A,II,II,4.0,INSERT_VALUES)); |
| 50 | } | ||
| 51 | |||
| 52 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY)); |
| 53 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY)); |
| 54 | |||
| 55 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| 56 | Create the eigensolver and set various options | ||
| 57 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ | ||
| 58 | |||
| 59 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(EPSCreate(PETSC_COMM_WORLD,&eps)); |
| 60 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(EPSSetOperators(eps,A,NULL)); |
| 61 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(EPSSetProblemType(eps,EPS_HEP)); |
| 62 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(EPSSetType(eps,EPSCHASE)); |
| 63 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(EPSSetDimensions(eps,6,PETSC_DETERMINE,PETSC_DETERMINE)); |
| 64 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(EPSSetWhichEigenpairs(eps,EPS_SMALLEST_REAL)); |
| 65 | 6 | deg = 20; | |
| 66 | 6 | opt = PETSC_TRUE; | |
| 67 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(EPSCHASESetDegree(eps,deg,opt)); |
| 68 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(EPSSetFromOptions(eps)); |
| 69 | |||
| 70 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| 71 | Compute eigenvalues and display info | ||
| 72 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ | ||
| 73 | |||
| 74 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(EPSSolve(eps)); |
| 75 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(EPSCHASEGetDegree(eps,°,&opt)); |
| 76 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(PetscPrintf(PETSC_COMM_WORLD," ChASE: using degree %" PetscInt_FMT ", optimization %s\n",deg,PetscBools[opt])); |
| 77 | |||
| 78 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(EPSErrorView(eps,EPS_ERROR_ABSOLUTE,NULL)); |
| 79 | |||
| 80 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(EPSDestroy(&eps)); |
| 81 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
6 | PetscCall(MatDestroy(&A)); |
| 82 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
6 | PetscCall(SlepcFinalize()); |
| 83 | return 0; | ||
| 84 | } | ||
| 85 | |||
| 86 | /*TEST | ||
| 87 | |||
| 88 | build: | ||
| 89 | requires: chase | ||
| 90 | |||
| 91 | testset: | ||
| 92 | requires: chase | ||
| 93 | output_file: output/test45_1.out | ||
| 94 | test: | ||
| 95 | suffix: 1 | ||
| 96 | test: | ||
| 97 | suffix: 2 | ||
| 98 | args: -mat_scalapack_grid_height 2 | ||
| 99 | nsize: 2 | ||
| 100 | |||
| 101 | TEST*/ | ||
| 102 |