Subversion Repositories slepc-dev

Rev

Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 982 Rev 983
Line 8... Line 8...
#include "petscblaslapack.h"
#include "petscblaslapack.h"
 
 
/*
/*
   User-defined routines
   User-defined routines
*/
*/
extern int MatLaplacian2D_Mult( Mat A, Vec x, Vec y );
PetscErrorCode MatLaplacian2D_Mult( Mat A, Vec x, Vec y );
 
 
#undef __FUNCT__
#undef __FUNCT__
#define __FUNCT__ "main"
#define __FUNCT__ "main"
int main( int argc, char **argv )
int main( int argc, char **argv )
{
{
Line 20... Line 20...
  EPS         eps;             /* eigenproblem solver context */
  EPS         eps;             /* eigenproblem solver context */
  EPSType     type;
  EPSType     type;
  PetscReal   error, tol, re, im;
  PetscReal   error, tol, re, im;
  PetscScalar kr, ki;
  PetscScalar kr, ki;
  PetscMPIInt size;
  PetscMPIInt size;
 
  PetscErrorCode ierr;
  PetscInt    N, n=10;
  PetscInt    N, n=10;
  int         nev, ierr, maxit, i, its, nconv;
  int         nev, maxit, i, its, nconv;
 
 
  SlepcInitialize(&argc,&argv,(char*)0,help);
  SlepcInitialize(&argc,&argv,(char*)0,help);
  ierr = MPI_Comm_size(PETSC_COMM_WORLD,&size);CHKERRQ(ierr);
  ierr = MPI_Comm_size(PETSC_COMM_WORLD,&size);CHKERRQ(ierr);
  if (size != 1) SETERRQ(1,"This is a uniprocessor example only!");
  if (size != 1) SETERRQ(1,"This is a uniprocessor example only!");
 
 
Line 171... Line 172...
                 |        ...  -I|
                 |        ...  -I|
                 |           -I T|
                 |           -I T|
 
 
    The subroutine TV is called to compute y<--T*x.
    The subroutine TV is called to compute y<--T*x.
 */
 */
int MatLaplacian2D_Mult( Mat A, Vec x, Vec y )
PetscErrorCode MatLaplacian2D_Mult( Mat A, Vec x, Vec y )
{
{
  void        *ctx;
  void           *ctx;
  int         ierr, nx, lo, j, one=1;
  PetscErrorCode ierr;
  PetscScalar *px, *py, dmone=-1.0;
  int            nx, lo, j, one=1;
 
  PetscScalar    *px, *py, dmone=-1.0;
 
 
 
  PetscFunctionBegin;
  ierr = MatShellGetContext( A, &ctx ); CHKERRQ(ierr);
  ierr = MatShellGetContext( A, &ctx ); CHKERRQ(ierr);
  nx = *(int *)ctx;
  nx = *(int *)ctx;
  ierr = VecGetArray( x, &px ); CHKERRQ(ierr);
  ierr = VecGetArray( x, &px ); CHKERRQ(ierr);
  ierr = VecGetArray( y, &py ); CHKERRQ(ierr);
  ierr = VecGetArray( y, &py ); CHKERRQ(ierr);
 
 
Line 198... Line 201...
  tv( nx, &px[lo], &py[lo]);
  tv( nx, &px[lo], &py[lo]);
  BLASaxpy_( &nx, &dmone, &px[lo-nx], &one, &py[lo], &one );
  BLASaxpy_( &nx, &dmone, &px[lo-nx], &one, &py[lo], &one );
 
 
  ierr = VecRestoreArray( x, &px ); CHKERRQ(ierr);
  ierr = VecRestoreArray( x, &px ); CHKERRQ(ierr);
  ierr = VecRestoreArray( y, &py ); CHKERRQ(ierr);
  ierr = VecRestoreArray( y, &py ); CHKERRQ(ierr);
 
  PetscFunctionReturn(0);
  return 0;
 
}
}