| 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 | Modification of the *temp* implementation of the BLOPEX multivector in order | ||
| 12 | to wrap created PETSc vectors as multivectors. | ||
| 13 | */ | ||
| 14 | |||
| 15 | #include <slepc/private/bvimpl.h> | ||
| 16 | #include <stdlib.h> | ||
| 17 | #include <interpreter.h> | ||
| 18 | #include <temp_multivector.h> | ||
| 19 | #include "blopex.h" | ||
| 20 | |||
| 21 | 108 | static void *mv_TempMultiVectorCreateFromBV(void *ii_,BlopexInt n,void *sample) | |
| 22 | { | ||
| 23 | 108 | BV bv = (BV)sample; | |
| 24 | 108 | Vec v; | |
| 25 | 108 | PetscInt i,l,k,nc,useconstr=PETSC_FALSE,flg; | |
| 26 | 108 | mv_TempMultiVector *x; | |
| 27 | 108 | mv_InterfaceInterpreter *ii = (mv_InterfaceInterpreter*)ii_; | |
| 28 | |||
| 29 | 108 | x = (mv_TempMultiVector*)malloc(sizeof(mv_TempMultiVector)); | |
| 30 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
108 | if (!x) SETERRABORT(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Allocation for x failed"); |
| 31 | |||
| 32 | 108 | x->interpreter = ii; | |
| 33 | 108 | x->numVectors = n; | |
| 34 | |||
| 35 | 108 | x->vector = (void**)calloc(n,sizeof(void*)); | |
| 36 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
108 | if (!x->vector) SETERRABORT(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Allocation for x->vector failed"); |
| 37 | |||
| 38 | 108 | x->ownsVectors = 1; | |
| 39 | 108 | x->mask = NULL; | |
| 40 | 108 | x->ownsMask = 0; | |
| 41 | |||
| 42 |
4/6✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
108 | PetscCallAbort(PETSC_COMM_SELF,BVGetActiveColumns(bv,&l,&k)); |
| 43 |
3/6✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
108 | PetscCallAbort(PETSC_COMM_SELF,PetscObjectComposedDataGetInt((PetscObject)bv,slepc_blopex_useconstr,useconstr,flg)); |
| 44 |
4/4✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
|
108 | if (!l && flg && useconstr) { |
| 45 |
4/6✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
54 | PetscCallAbort(PETSC_COMM_SELF,BVGetNumConstraints(bv,&nc)); |
| 46 | 54 | l = -nc; | |
| 47 | } | ||
| 48 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
108 | if (n != k-l) SETERRABORT(PETSC_COMM_SELF,PETSC_ERR_PLIB,"BV active columns plus constraints do not match argument n"); |
| 49 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
|
366 | for (i=0;i<n;i++) { |
| 50 |
4/6✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
258 | PetscCallAbort(PETSC_COMM_SELF,BVGetColumn(bv,l+i,&v)); |
| 51 |
4/6✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
258 | PetscCallAbort(PETSC_COMM_SELF,PetscObjectReference((PetscObject)v)); |
| 52 | 258 | x->vector[i] = (void*)v; | |
| 53 |
4/6✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
258 | PetscCallAbort(PETSC_COMM_SELF,BVRestoreColumn(bv,l+i,&v)); |
| 54 | } | ||
| 55 | 108 | return x; | |
| 56 | } | ||
| 57 | |||
| 58 | /* | ||
| 59 | Create an InterfaceInterpreter using the PETSc implementation | ||
| 60 | but overloading CreateMultiVector that doesn't create any | ||
| 61 | new vector. | ||
| 62 | */ | ||
| 63 | 42 | int SLEPCSetupInterpreter(mv_InterfaceInterpreter *i) | |
| 64 | { | ||
| 65 | 42 | PETSCSetupInterpreter(i); | |
| 66 | 42 | i->CreateMultiVector = mv_TempMultiVectorCreateFromBV; | |
| 67 | |||
| 68 | 42 | return 0; | |
| 69 | } | ||
| 70 |