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
6 dsic.upv.es!jroman 1
/*
2
    Shift spectral transformation, applies (A + sigma I) as operator, or
3
    inv(B)(A + sigma B) for generalized problems
1376 slepc 4
 
5
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
6
      SLEPc - Scalable Library for Eigenvalue Problem Computations
7
      Copyright (c) 2002-2007, Universidad Politecnica de Valencia, Spain
8
 
9
      This file is part of SLEPc. See the README file for conditions of use
10
      and additional information.
11
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
6 dsic.upv.es!jroman 12
*/
1376 slepc 13
 
6 dsic.upv.es!jroman 14
#include "src/st/stimpl.h"          /*I "slepcst.h" I*/
15
 
16
#undef __FUNCT__  
17
#define __FUNCT__ "STApply_Shift"
476 dsic.upv.es!antodo 18
PetscErrorCode STApply_Shift(ST st,Vec x,Vec y)
6 dsic.upv.es!jroman 19
{
476 dsic.upv.es!antodo 20
  PetscErrorCode ierr;
6 dsic.upv.es!jroman 21
 
22
  PetscFunctionBegin;
23
  if (st->B) {
24
    /* generalized eigenproblem: y = (B^-1 A + sI) x */
344 dsic.upv.es!antodo 25
    ierr = MatMult(st->A,x,st->w);CHKERRQ(ierr);
26
    ierr = STAssociatedKSPSolve(st,st->w,y);CHKERRQ(ierr);
6 dsic.upv.es!jroman 27
  }
28
  else {
29
    /* standard eigenproblem: y = (A + sI) x */
30
    ierr = MatMult(st->A,x,y);CHKERRQ(ierr);
109 dsic.upv.es!antodo 31
  }
133 dsic.upv.es!antodo 32
  if (st->sigma != 0.0) {
828 dsic.upv.es!antodo 33
    ierr = VecAXPY(y,st->sigma,x);CHKERRQ(ierr);
6 dsic.upv.es!jroman 34
  }
35
  PetscFunctionReturn(0);
36
}
37
 
38
#undef __FUNCT__  
780 dsic.upv.es!jroman 39
#define __FUNCT__ "STApplyTranspose_Shift"
40
PetscErrorCode STApplyTranspose_Shift(ST st,Vec x,Vec y)
41
{
42
  PetscErrorCode ierr;
43
 
44
  PetscFunctionBegin;
45
  if (st->B) {
46
    /* generalized eigenproblem: y = (A^T B^-T + sI) x */
47
    ierr = STAssociatedKSPSolveTranspose(st,x,st->w);CHKERRQ(ierr);
48
    ierr = MatMultTranspose(st->A,st->w,y);CHKERRQ(ierr);
49
  }
50
  else {
51
    /* standard eigenproblem: y = (A^T + sI) x */
52
    ierr = MatMultTranspose(st->A,x,y);CHKERRQ(ierr);
53
  }
54
  if (st->sigma != 0.0) {
828 dsic.upv.es!antodo 55
    ierr = VecAXPY(y,st->sigma,x);CHKERRQ(ierr);
780 dsic.upv.es!jroman 56
  }
57
  PetscFunctionReturn(0);
58
}
59
 
60
#undef __FUNCT__  
6 dsic.upv.es!jroman 61
#define __FUNCT__ "STBackTransform_Shift"
476 dsic.upv.es!antodo 62
PetscErrorCode STBackTransform_Shift(ST st,PetscScalar *eigr,PetscScalar *eigi)
6 dsic.upv.es!jroman 63
{
64
  PetscFunctionBegin;
65
  if (eigr) *eigr -= st->sigma;
66
  PetscFunctionReturn(0);
67
}
68
 
69
#undef __FUNCT__  
70
#define __FUNCT__ "STSetUp_Shift"
476 dsic.upv.es!antodo 71
PetscErrorCode STSetUp_Shift(ST st)
6 dsic.upv.es!jroman 72
{
476 dsic.upv.es!antodo 73
  PetscErrorCode ierr;
6 dsic.upv.es!jroman 74
 
75
  PetscFunctionBegin;
246 dsic.upv.es!antodo 76
  if (st->B) {
77
    ierr = KSPSetOperators(st->ksp,st->B,st->B,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr);
18 dsic.upv.es!jroman 78
    ierr = KSPSetUp(st->ksp);CHKERRQ(ierr);
6 dsic.upv.es!jroman 79
  }
80
  PetscFunctionReturn(0);
81
}
82
 
438 dsic.upv.es!antodo 83
#undef __FUNCT__  
84
#define __FUNCT__ "STView_Shift"
476 dsic.upv.es!antodo 85
PetscErrorCode STView_Shift(ST st,PetscViewer viewer)
438 dsic.upv.es!antodo 86
{
476 dsic.upv.es!antodo 87
  PetscErrorCode ierr;
438 dsic.upv.es!antodo 88
 
89
  PetscFunctionBegin;
90
  if (st->B) {
91
    ierr = STView_Default(st,viewer);CHKERRQ(ierr);
92
  }
93
  PetscFunctionReturn(0);
94
}
95
 
6 dsic.upv.es!jroman 96
EXTERN_C_BEGIN
97
#undef __FUNCT__  
98
#define __FUNCT__ "STCreate_Shift"
476 dsic.upv.es!antodo 99
PetscErrorCode STCreate_Shift(ST st)
6 dsic.upv.es!jroman 100
{
101
  PetscFunctionBegin;
1358 slepc 102
  st->ops->apply           = STApply_Shift;
103
  st->ops->getbilinearform = STGetBilinearForm_Default;
104
  st->ops->applytrans      = STApplyTranspose_Shift;
105
  st->ops->backtr          = STBackTransform_Shift;
106
  st->ops->setup           = STSetUp_Shift;
107
  st->ops->view            = STView_Shift;
108
  st->checknullspace       = 0;
6 dsic.upv.es!jroman 109
  PetscFunctionReturn(0);
110
}
111
EXTERN_C_END
112