Date: 2017-05-17T08:27:38+00:00

Actual source code: slepcmath.h
slepc-3.7.4 2017-05-17
Report Typos and Errors

      1: /*
      2:    SLEPc mathematics include file. Defines basic operations and functions.
      3:    This file is included by slepcsys.h and should not be used directly.

      5:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      6:    SLEPc - Scalable Library for Eigenvalue Problem Computations
      7:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

      9:    This file is part of SLEPc.

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

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

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

     28: /*
     29:     Default tolerance for the different solvers, depending on the precision
     30: */
     31: #if defined(PETSC_USE_REAL_SINGLE)
     32: #  define SLEPC_DEFAULT_TOL   1e-6
     33: #elif defined(PETSC_USE_REAL_DOUBLE)
     34: #  define SLEPC_DEFAULT_TOL   1e-8
     35: #elif defined(PETSC_USE_REAL___FLOAT128)
     36: #  define SLEPC_DEFAULT_TOL   1e-16
     37: #else
     38: #  define SLEPC_DEFAULT_TOL   1e-7
     39: #endif

     41: /*@C
     42:    SlepcAbs - Returns sqrt(x**2+y**2), taking care not to cause unnecessary
     43:    overflow. It is based on LAPACK's DLAPY2.

     45:    Not Collective

     47:    Input parameters:
     48: .  x,y - the real numbers

     50:    Output parameter:
     51: .  return - the result

     53:    Note:
     54:    This function is not available from Fortran.

     56:    Level: developer
     57: @*/
     58: PETSC_STATIC_INLINE PetscReal SlepcAbs(PetscReal x,PetscReal y)
     59: {
     60:   PetscReal w,z,t,xabs=PetscAbs(x),yabs=PetscAbs(y);

     62:   w = PetscMax(xabs,yabs);
     63:   z = PetscMin(xabs,yabs);
     64:   if (z == 0.0) return w;
     65:   t = z/w;
     66:   return w*PetscSqrtReal(1.0+t*t);
     67: }

     69: /*MC
     70:    SlepcAbsEigenvalue - Returns the absolute value of a complex number given
     71:    its real and imaginary parts.

     73:    Synopsis:
     74:    PetscReal SlepcAbsEigenvalue(PetscScalar x,PetscScalar y)

     76:    Not Collective

     78:    Input parameters:
     79: +  x  - the real part of the complex number
     80: -  y  - the imaginary part of the complex number

     82:    Notes:
     83:    This function computes sqrt(x**2+y**2), taking care not to cause unnecessary
     84:    overflow. It is based on LAPACK's DLAPY2.

     86:    This function is not available from Fortran.

     88:    Level: developer
     89: M*/
     90: #if !defined(PETSC_USE_COMPLEX)
     91: #define SlepcAbsEigenvalue(x,y) SlepcAbs(x,y)
     92: #else
     93: #define SlepcAbsEigenvalue(x,y) PetscAbsScalar(x)
     94: #endif

     96: #endif