Date: 2016-03-29T14:59:42+00:00

Actual source code: fnimpl.h
slepc-3.6.3 2016-03-29
Report Typos and Errors

      1: /*
      2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
      4:    Copyright (c) 2002-2015, Universitat Politecnica de Valencia, Spain

      6:    This file is part of SLEPc.

      8:    SLEPc is free software: you can redistribute it and/or modify it under  the
      9:    terms of version 3 of the GNU Lesser General Public License as published by
     10:    the Free Software Foundation.

     12:    SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
     13:    WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
     14:    FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
     15:    more details.

     17:    You  should have received a copy of the GNU Lesser General  Public  License
     18:    along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
     19:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     20: */

     22: #if !defined(_FNIMPL)
     23: #define _FNIMPL

     25: #include <slepcfn.h>
     26: #include <slepc/private/slepcimpl.h>

     28: PETSC_EXTERN PetscBool FNRegisterAllCalled;
     29: PETSC_EXTERN PetscErrorCode FNRegisterAll(void);
     30: PETSC_EXTERN PetscLogEvent FN_Evaluate;

     32: typedef struct _FNOps *FNOps;

     34: struct _FNOps {
     35:   PetscErrorCode (*evaluatefunction)(FN,PetscScalar,PetscScalar*);
     36:   PetscErrorCode (*evaluatederivative)(FN,PetscScalar,PetscScalar*);
     37:   PetscErrorCode (*evaluatefunctionmat)(FN,Mat,Mat);
     38:   PetscErrorCode (*evaluatefunctionmatsym)(FN,Mat,Mat);
     39:   PetscErrorCode (*setfromoptions)(PetscOptions*,FN);
     40:   PetscErrorCode (*view)(FN,PetscViewer);
     41:   PetscErrorCode (*duplicate)(FN,MPI_Comm,FN*);
     42:   PetscErrorCode (*destroy)(FN);
     43: };

     45: struct _p_FN {
     46:   PETSCHEADER(struct _FNOps);
     47:   /*------------------------- User parameters --------------------------*/
     48:   PetscScalar        alpha;   /* inner scaling (argument) */
     49:   PetscScalar        beta;    /* outer scaling (result) */

     51:   /*---------------------- Cached data and workspace -------------------*/
     52:   Mat                W;       /* workspace matrix */
     53:   void               *data;
     54: };

     58: /*
     59:   FN_AllocateWorkMat - Allocate a working Mat of appropriate size if not available already.
     60: */
     61: PETSC_STATIC_INLINE PetscErrorCode FN_AllocateWorkMat(FN fn,Mat A)
     62: {
     64:   PetscInt       n,na;
     65:   PetscBool      create=PETSC_FALSE;

     68:   if (!fn->W) create=PETSC_TRUE;
     69:   else {
     70:     MatGetSize(fn->W,&n,NULL);
     71:     MatGetSize(A,&na,NULL);
     72:     if (n!=na) {
     73:       MatDestroy(&fn->W);
     74:       create=PETSC_TRUE;
     75:     }
     76:   }
     77:   if (create) {
     78:     MatDuplicate(A,MAT_COPY_VALUES,&fn->W);
     79:     PetscLogObjectParent((PetscObject)fn,(PetscObject)fn->W);
     80:   } else {
     81:     MatCopy(A,fn->W,SAME_NONZERO_PATTERN);
     82:   }
     83:   return(0);
     84: }

     86: #endif